diff options
Diffstat (limited to 'validation/optim')
| -rw-r--r-- | validation/optim/and-extend.c | 27 | ||||
| -rw-r--r-- | validation/optim/and-extendx.c | 24 | ||||
| -rw-r--r-- | validation/optim/and-lsr.c | 16 | ||||
| -rw-r--r-- | validation/optim/and-trunc.c | 20 | ||||
| -rw-r--r-- | validation/optim/bool-context-fp.c | 16 | ||||
| -rw-r--r-- | validation/optim/ext-trunc-greater.c | 17 | ||||
| -rw-r--r-- | validation/optim/ext-trunc-same.c | 19 | ||||
| -rw-r--r-- | validation/optim/ext-trunc-smaller.c | 18 | ||||
| -rw-r--r-- | validation/optim/lsr-asr.c | 42 | ||||
| -rw-r--r-- | validation/optim/mask-lsr.c | 15 | ||||
| -rw-r--r-- | validation/optim/mask-out.c | 13 | ||||
| -rw-r--r-- | validation/optim/sext-sext.c | 12 | ||||
| -rw-r--r-- | validation/optim/sext.c | 15 | ||||
| -rw-r--r-- | validation/optim/shift-big.c | 82 | ||||
| -rw-r--r-- | validation/optim/shift-shift.c | 149 | ||||
| -rw-r--r-- | validation/optim/shift-zext.c | 13 | ||||
| -rw-r--r-- | validation/optim/store-load-bitfield.c | 50 | ||||
| -rw-r--r-- | validation/optim/trunc-mask-zext.c | 13 | ||||
| -rw-r--r-- | validation/optim/zext-and.c | 12 | ||||
| -rw-r--r-- | validation/optim/zext-and1.c | 12 | ||||
| -rw-r--r-- | validation/optim/zext-asr.c | 13 | ||||
| -rw-r--r-- | validation/optim/zext-sext.c | 13 | ||||
| -rw-r--r-- | validation/optim/zext-zext.c | 13 |
23 files changed, 616 insertions, 8 deletions
diff --git a/validation/optim/and-extend.c b/validation/optim/and-extend.c new file mode 100644 index 00000000..eb589236 --- /dev/null +++ b/validation/optim/and-extend.c @@ -0,0 +1,27 @@ +typedef unsigned short u16; +typedef short s16; +typedef unsigned int u32; +typedef int s32; + +u32 ufoo(u32 x) +{ + u16 i = ((u16)x) & 0x7fffU; + return i; +} + +u32 sfoo(u32 x) +{ + s16 i = ((s16)x) & 0x7fff; + return i; +} + +/* + * check-name: and-extend + * check-command: test-linearize -Wno-decl $file + * + * check-output-ignore + * check-output-excludes: trunc\\. + * check-output-excludes: zext\\. + * check-output-excludes: sext\\. + * check-output-contains: and\\.32.*0x7fff + */ diff --git a/validation/optim/and-extendx.c b/validation/optim/and-extendx.c new file mode 100644 index 00000000..5c181c93 --- /dev/null +++ b/validation/optim/and-extendx.c @@ -0,0 +1,24 @@ +typedef unsigned short u16; +typedef short s16; +typedef unsigned int u32; +typedef int s32; +typedef unsigned long long u64; +typedef long long s64; + +u64 ufoo(int x) +{ + return x & 0x7fff; +} + +u64 sfoo(int x) +{ + return x & 0x7fff; +} + +/* + * check-name: and-extend + * check-command: test-linearize -Wno-decl $file + * + * check-output-ignore + * check-output-contains: and\\.64.*0x7fff + */ diff --git a/validation/optim/and-lsr.c b/validation/optim/and-lsr.c new file mode 100644 index 00000000..df6b72f3 --- /dev/null +++ b/validation/optim/and-lsr.c @@ -0,0 +1,16 @@ +// (x & M) >> S to (x >> S) & (M >> S) + +unsigned int foo(unsigned int x) +{ + return (x & 0xffff) >> 12; +} + +/* + * check-name: and-lsr + * check-command: test-linearize -Wno-decl $file + * check-known-to-fail + * + * check-output-ignore + * check-output-contains: and\\..*\\$15 + * check-output-excludes: and\\..*\\$0xffff + */ diff --git a/validation/optim/and-trunc.c b/validation/optim/and-trunc.c new file mode 100644 index 00000000..df1e4d03 --- /dev/null +++ b/validation/optim/and-trunc.c @@ -0,0 +1,20 @@ +short smask(short x) +{ + return x & (short) 0x7fff; +} + +short umask(unsigned short x) +{ + return x & (unsigned short) 0x7fff; +} + +/* + * check-name: and-trunc + * check-command: test-linearize -Wno-decl $file + * + * check-output-ignore + * check-output-excludes: sext\\. + * check-output-excludes: zext\\. + * check-output-excludes: trunc\\. + * check-output-contains: and\\.16 + */ diff --git a/validation/optim/bool-context-fp.c b/validation/optim/bool-context-fp.c index 6325ee36..c41370ba 100644 --- a/validation/optim/bool-context-fp.c +++ b/validation/optim/bool-context-fp.c @@ -18,7 +18,7 @@ int ifand(float a, float b) { return a && b; } bfimp: .L0: <entry-point> - setfval.32 %r2 <- 0.000000 + setfval.32 %r2 <- 0.000000e+00 fcmpune.1 %r3 <- %arg1, %r2 ret.1 %r3 @@ -26,7 +26,7 @@ bfimp: bfexp: .L2: <entry-point> - setfval.32 %r6 <- 0.000000 + setfval.32 %r6 <- 0.000000e+00 fcmpune.1 %r7 <- %arg1, %r6 ret.1 %r7 @@ -34,7 +34,7 @@ bfexp: bfnot: .L4: <entry-point> - setfval.32 %r10 <- 0.000000 + setfval.32 %r10 <- 0.000000e+00 fcmpoeq.1 %r12 <- %arg1, %r10 ret.1 %r12 @@ -42,7 +42,7 @@ bfnot: ifnot: .L6: <entry-point> - setfval.32 %r15 <- 0.000000 + setfval.32 %r15 <- 0.000000e+00 fcmpoeq.32 %r16 <- %arg1, %r15 ret.32 %r16 @@ -50,7 +50,7 @@ ifnot: bfior: .L8: <entry-point> - setfval.32 %r19 <- 0.000000 + setfval.32 %r19 <- 0.000000e+00 fcmpune.1 %r20 <- %arg1, %r19 fcmpune.1 %r23 <- %arg2, %r19 or.1 %r24 <- %r20, %r23 @@ -60,7 +60,7 @@ bfior: ifior: .L10: <entry-point> - setfval.32 %r29 <- 0.000000 + setfval.32 %r29 <- 0.000000e+00 fcmpune.1 %r30 <- %arg1, %r29 fcmpune.1 %r33 <- %arg2, %r29 or.1 %r34 <- %r30, %r33 @@ -71,7 +71,7 @@ ifior: bfand: .L12: <entry-point> - setfval.32 %r38 <- 0.000000 + setfval.32 %r38 <- 0.000000e+00 fcmpune.1 %r39 <- %arg1, %r38 fcmpune.1 %r42 <- %arg2, %r38 and.1 %r43 <- %r39, %r42 @@ -81,7 +81,7 @@ bfand: ifand: .L14: <entry-point> - setfval.32 %r48 <- 0.000000 + setfval.32 %r48 <- 0.000000e+00 fcmpune.1 %r49 <- %arg1, %r48 fcmpune.1 %r52 <- %arg2, %r48 and.1 %r53 <- %r49, %r52 diff --git a/validation/optim/ext-trunc-greater.c b/validation/optim/ext-trunc-greater.c new file mode 100644 index 00000000..b682fc5d --- /dev/null +++ b/validation/optim/ext-trunc-greater.c @@ -0,0 +1,17 @@ +short sgt(char x) +{ + return (int) x; +} + +short ugt(unsigned char x) +{ + return (int) x; +} + +/* + * check-name: ext-trunc-greater + * check-command: test-linearize -Wno-decl $file + * + * check-output-ignore + * check-output-excludes: trunc\\. + */ diff --git a/validation/optim/ext-trunc-same.c b/validation/optim/ext-trunc-same.c new file mode 100644 index 00000000..2bfcf030 --- /dev/null +++ b/validation/optim/ext-trunc-same.c @@ -0,0 +1,19 @@ +short seq(short x) +{ + return (int) x; +} + +short ueq(unsigned short x) +{ + return (int) x; +} + +/* + * check-name: ext-trunc-same + * check-command: test-linearize -Wno-decl $file + * + * check-output-ignore + * check-output-excludes: trunc\\. + * check-output-excludes: sext\\. + * check-output-excludes: zext\\. + */ diff --git a/validation/optim/ext-trunc-smaller.c b/validation/optim/ext-trunc-smaller.c new file mode 100644 index 00000000..194c98d7 --- /dev/null +++ b/validation/optim/ext-trunc-smaller.c @@ -0,0 +1,18 @@ +char slt(short x) +{ + return (int) x; +} + +char ult(unsigned short x) +{ + return (int) x; +} + +/* + * check-name: ext-trunc-smaller + * check-command: test-linearize -Wno-decl $file + * + * check-output-ignore + * check-output-excludes: sext\\. + * check-output-excludes: zext\\. + */ diff --git a/validation/optim/lsr-asr.c b/validation/optim/lsr-asr.c new file mode 100644 index 00000000..aee46940 --- /dev/null +++ b/validation/optim/lsr-asr.c @@ -0,0 +1,42 @@ +int lsrasr0(unsigned int x) +{ + return ((int) (x >> 15)) >> 15; +} + +int lsrasr1(unsigned int x) +{ + return ((int) (x >> 16)) >> 15; +} + +int lsrasr2(unsigned int x) +{ + return ((int) (x >> 16)) >> 16; +} + +/* + * check-name: lsr-asr + * check-command: test-linearize -Wno-decl $file + * + * check-output-start +lsrasr0: +.L0: + <entry-point> + lsr.32 %r3 <- %arg1, $30 + ret.32 %r3 + + +lsrasr1: +.L2: + <entry-point> + lsr.32 %r7 <- %arg1, $31 + ret.32 %r7 + + +lsrasr2: +.L4: + <entry-point> + ret.32 $0 + + + * check-output-end + */ diff --git a/validation/optim/mask-lsr.c b/validation/optim/mask-lsr.c new file mode 100644 index 00000000..1d37c91e --- /dev/null +++ b/validation/optim/mask-lsr.c @@ -0,0 +1,15 @@ +// ((x & M) | y) >> S to (y >> S) when (M >> S) == 0 + +unsigned int foo(unsigned int x, unsigned int y) +{ + return ((x & 0xff) | y) >> 8; +} + +/* + * check-name: mask-lsr + * check-command: test-linearize -Wno-decl $file + * check-known-to-fail + * + * check-output-ignore + * check-output-excludes: %arg1 + */ diff --git a/validation/optim/mask-out.c b/validation/optim/mask-out.c new file mode 100644 index 00000000..bf116873 --- /dev/null +++ b/validation/optim/mask-out.c @@ -0,0 +1,13 @@ +unsigned mask(unsigned a, unsigned b) +{ + return ((a & 0xffff0000) | b) & 0x0000ffff; +} + +/* + * check-name: mask-out + * check-command: test-linearize -Wno-decl $file + * check-known-to-fail + * + * check-output-ignore + * check-output-excludes: %arg1 + */ diff --git a/validation/optim/sext-sext.c b/validation/optim/sext-sext.c new file mode 100644 index 00000000..604a7dd4 --- /dev/null +++ b/validation/optim/sext-sext.c @@ -0,0 +1,12 @@ +int foo(signed char offset) +{ + return (int)(short) offset; +} + +/* + * check-name: sext-sext + * check-command: test-linearize -Wno-decl $file + * + * check-output-ignore + * check-output-pattern(1): sext\\. + */ diff --git a/validation/optim/sext.c b/validation/optim/sext.c new file mode 100644 index 00000000..719730d5 --- /dev/null +++ b/validation/optim/sext.c @@ -0,0 +1,15 @@ +int sext(int x) +{ + return (x << 5) >> 5; +} + +/* + * check-name: sext + * check-command: test-linearize -Wno-decl $file + * check-known-to-fail + * + * check-output-ignore + * check-output-contains: sext\\.$27 + * check-output-excludes: asr\\. + * check-output-excludes: shl\\. + */ diff --git a/validation/optim/shift-big.c b/validation/optim/shift-big.c new file mode 100644 index 00000000..84bcd2ce --- /dev/null +++ b/validation/optim/shift-big.c @@ -0,0 +1,82 @@ +typedef unsigned int u32; +typedef int s32; + +s32 asr31(s32 a) { return a >> 31; } +s32 asr32(s32 a) { return a >> 32; } +s32 asr33(s32 a) { return a >> 33; } + +u32 lsr31(u32 a) { return a >> 31; } +u32 lsr32(u32 a) { return a >> 32; } +u32 lsr33(u32 a) { return a >> 33; } + +u32 shl31(u32 a) { return a << 31; } +u32 shl32(u32 a) { return a << 32; } +u32 shl33(u32 a) { return a << 33; } + +/* + * check-name: optim/shift-big.c + * check-command: test-linearize -Wno-decl -m64 $file + * + * check-error-ignore + * check-output-start +asr31: +.L0: + <entry-point> + asr.32 %r2 <- %arg1, $31 + ret.32 %r2 + + +asr32: +.L2: + <entry-point> + asr.32 %r5 <- %arg1, $32 + ret.32 %r5 + + +asr33: +.L4: + <entry-point> + asr.32 %r8 <- %arg1, $33 + ret.32 %r8 + + +lsr31: +.L6: + <entry-point> + lsr.32 %r11 <- %arg1, $31 + ret.32 %r11 + + +lsr32: +.L8: + <entry-point> + ret.32 $0 + + +lsr33: +.L10: + <entry-point> + ret.32 $0 + + +shl31: +.L12: + <entry-point> + shl.32 %r20 <- %arg1, $31 + ret.32 %r20 + + +shl32: +.L14: + <entry-point> + ret.32 $0 + + +shl33: +.L16: + <entry-point> + ret.32 $0 + + + * check-output-end + */ diff --git a/validation/optim/shift-shift.c b/validation/optim/shift-shift.c new file mode 100644 index 00000000..12a4b7d4 --- /dev/null +++ b/validation/optim/shift-shift.c @@ -0,0 +1,149 @@ +unsigned int shl0(unsigned int x) +{ + return x << 15 << 15; +} + +unsigned int shl1(unsigned int x) +{ + return x << 16 << 15; +} + +unsigned int shl2(unsigned int x) +{ + return x << 16 << 16; +} + +unsigned int shl3(unsigned int x) +{ + return x << 12 << 10 << 10; +} + + +unsigned int lsr0(unsigned int x) +{ + return x >> 15 >> 15; +} + +unsigned int lsr1(unsigned int x) +{ + return x >> 16 >> 15; +} + +unsigned int lsr2(unsigned int x) +{ + return x >> 16 >> 16; +} + +unsigned int lsr3(unsigned int x) +{ + return x >> 12 >> 10 >> 10; +} + + +int asr0(int x) +{ + return x >> 15 >> 15; +} + +int asr1(int x) +{ + return x >> 16 >> 15; +} + +int asr2(int x) +{ + return x >> 16 >> 16; +} + +int asr3(int x) +{ + return x >> 12 >> 10 >> 10; +} + +/* + * check-name: shift-shift + * check-command: test-linearize -Wno-decl $file + * + * check-output-start +shl0: +.L0: + <entry-point> + shl.32 %r3 <- %arg1, $30 + ret.32 %r3 + + +shl1: +.L2: + <entry-point> + shl.32 %r7 <- %arg1, $31 + ret.32 %r7 + + +shl2: +.L4: + <entry-point> + ret.32 $0 + + +shl3: +.L6: + <entry-point> + ret.32 $0 + + +lsr0: +.L8: + <entry-point> + lsr.32 %r20 <- %arg1, $30 + ret.32 %r20 + + +lsr1: +.L10: + <entry-point> + lsr.32 %r24 <- %arg1, $31 + ret.32 %r24 + + +lsr2: +.L12: + <entry-point> + ret.32 $0 + + +lsr3: +.L14: + <entry-point> + ret.32 $0 + + +asr0: +.L16: + <entry-point> + asr.32 %r37 <- %arg1, $30 + ret.32 %r37 + + +asr1: +.L18: + <entry-point> + asr.32 %r41 <- %arg1, $31 + ret.32 %r41 + + +asr2: +.L20: + <entry-point> + asr.32 %r45 <- %arg1, $31 + ret.32 %r45 + + +asr3: +.L22: + <entry-point> + asr.32 %r50 <- %arg1, $31 + ret.32 %r50 + + + * check-output-end + */ diff --git a/validation/optim/shift-zext.c b/validation/optim/shift-zext.c new file mode 100644 index 00000000..070416f3 --- /dev/null +++ b/validation/optim/shift-zext.c @@ -0,0 +1,13 @@ +unsigned int foo(unsigned int x) +{ + return (x << 20) >> 20; +} + +/* + * check-name: shift-zext + * check-command: test-linearize -Wno-decl $file + * check-known-to-fail + * + * check-output-ignore + * check-output-contains: and\\..*%arg1, \\$0xfff + */ diff --git a/validation/optim/store-load-bitfield.c b/validation/optim/store-load-bitfield.c new file mode 100644 index 00000000..1d8ff240 --- /dev/null +++ b/validation/optim/store-load-bitfield.c @@ -0,0 +1,50 @@ +int ufoo(unsigned int a) +{ + struct u { + unsigned int :2; + unsigned int a:3; + } bf; + + bf.a = a; + return bf.a; +} + +int sfoo(int a) +{ + struct s { + signed int :2; + signed int a:3; + } bf; + + bf.a = a; + return bf.a; +} + +/* + * check-name: optim store/load bitfields + * check-command: test-linearize -Wno-decl $file + * + * check-output-start +ufoo: +.L0: + <entry-point> + and.32 %r4 <- %arg1, $7 + shl.32 %r5 <- %r4, $2 + lsr.32 %r9 <- %r5, $2 + and.32 %r11 <- %r9, $7 + ret.32 %r11 + + +sfoo: +.L2: + <entry-point> + and.32 %r16 <- %arg1, $7 + shl.32 %r17 <- %r16, $2 + lsr.32 %r21 <- %r17, $2 + trunc.3 %r22 <- (32) %r21 + sext.32 %r23 <- (3) %r22 + ret.32 %r23 + + + * check-output-end + */ diff --git a/validation/optim/trunc-mask-zext.c b/validation/optim/trunc-mask-zext.c new file mode 100644 index 00000000..9b604174 --- /dev/null +++ b/validation/optim/trunc-mask-zext.c @@ -0,0 +1,13 @@ +unsigned long long foo(unsigned long long x) +{ + return (((unsigned int) x) & 0x7ffU); +} + +/* + * check-name: trunc-mask-zext + * check-command: test-linearize -Wno-decl $file + * + * check-output-ignore + * check-output-excludes: trunc\\. + * check-output-excludes: zext\\. + */ diff --git a/validation/optim/zext-and.c b/validation/optim/zext-and.c new file mode 100644 index 00000000..a3153bf7 --- /dev/null +++ b/validation/optim/zext-and.c @@ -0,0 +1,12 @@ +unsigned int foo(unsigned char x) +{ + return (unsigned int)x & 0xffffU; +} + +/* + * check-name: zext-and + * check-command: test-linearize -Wno-decl $file + * + * check-output-ignore + * check-output-excludes: and\\. + */ diff --git a/validation/optim/zext-and1.c b/validation/optim/zext-and1.c new file mode 100644 index 00000000..c99a0e62 --- /dev/null +++ b/validation/optim/zext-and1.c @@ -0,0 +1,12 @@ +unsigned int bar(unsigned char x) +{ + return (unsigned int)x & 0xff01U; +} + +/* + * check-name: zext-and1 + * check-command: test-linearize -Wno-decl $file + * + * check-output-ignore + * check-output-contains: and\\..*\\$1 + */ diff --git a/validation/optim/zext-asr.c b/validation/optim/zext-asr.c new file mode 100644 index 00000000..5f235ad8 --- /dev/null +++ b/validation/optim/zext-asr.c @@ -0,0 +1,13 @@ +unsigned short foo(unsigned short a) +{ + return a >> 16; +} + +/* + * check-name: zext-asr + * check-command: test-linearize -Wno-decl $file + * + * check-output-ignore + * check-output-contains: ret\\..*\\$0 + * check-output-excludes: asr\\. + */ diff --git a/validation/optim/zext-sext.c b/validation/optim/zext-sext.c new file mode 100644 index 00000000..1fe3900d --- /dev/null +++ b/validation/optim/zext-sext.c @@ -0,0 +1,13 @@ +int foo(unsigned char offset) +{ + return (int)(short) offset; +} + +/* + * check-name: zext-sext + * check-command: test-linearize -Wno-decl $file + * + * check-output-ignore + * check-output-excludes: sext\\. + * check-output-pattern(1): zext\\. + */ diff --git a/validation/optim/zext-zext.c b/validation/optim/zext-zext.c new file mode 100644 index 00000000..986d2242 --- /dev/null +++ b/validation/optim/zext-zext.c @@ -0,0 +1,13 @@ +int foo(unsigned char offset) +{ + return (int)(unsigned short) offset; +} + +/* + * check-name: zext-zext + * check-command: test-linearize -Wno-decl $file + * + * check-output-ignore + * check-output-excludes: sext\\. + * check-output-pattern(1): zext\\. + */ |
