diff options
Diffstat (limited to 'validation/optim')
| -rw-r--r-- | validation/optim/bits-not-zero.c | 30 | ||||
| -rw-r--r-- | validation/optim/bool-context-fp.c | 48 | ||||
| -rw-r--r-- | validation/optim/bool-int-bool.c | 12 | ||||
| -rw-r--r-- | validation/optim/bool-simplify.c | 25 | ||||
| -rw-r--r-- | validation/optim/bool-simplify2.c | 231 |
5 files changed, 346 insertions, 0 deletions
diff --git a/validation/optim/bits-not-zero.c b/validation/optim/bits-not-zero.c new file mode 100644 index 00000000..189fe331 --- /dev/null +++ b/validation/optim/bits-not-zero.c @@ -0,0 +1,30 @@ +int or_not0(int a) { return a | ~0; } +int and_not0(int a) { return a & ~0; } +int xor_not0(int a) { return a ^ ~0; } + +/* + * check-name: bool-not-zero + * check-command: test-linearize -Wno-decl $file + * + * check-output-start +or_not0: +.L0: + <entry-point> + ret.32 $0xffffffff + + +and_not0: +.L2: + <entry-point> + ret.32 %arg1 + + +xor_not0: +.L4: + <entry-point> + not.32 %r8 <- %arg1 + ret.32 %r8 + + + * check-output-end + */ diff --git a/validation/optim/bool-context-fp.c b/validation/optim/bool-context-fp.c index ad075c56..50e96825 100644 --- a/validation/optim/bool-context-fp.c +++ b/validation/optim/bool-context-fp.c @@ -5,6 +5,10 @@ bool bfexp(float a) { return (bool)a; } bool bfnot(float a) { return !a; } int ifnot(float a) { return !a; } +bool bfior(float a, float b) { return a || b; } +int ifior(float a, float b) { return a || b; } +bool bfand(float a, float b) { return a && b; } +int ifand(float a, float b) { return a && b; } /* * check-name: bool context fp @@ -43,5 +47,49 @@ ifnot: ret.32 %r16 +bfior: +.L8: + <entry-point> + setfval.32 %r19 <- 0.000000 + fcmpune.1 %r20 <- %arg1, %r19 + fcmpune.1 %r23 <- %arg2, %r19 + or.1 %r24 <- %r20, %r23 + setne.1 %r26 <- %r24, $0 + ret.1 %r26 + + +ifior: +.L10: + <entry-point> + setfval.32 %r29 <- 0.000000 + fcmpune.1 %r30 <- %arg1, %r29 + fcmpune.1 %r33 <- %arg2, %r29 + or.1 %r34 <- %r30, %r33 + zext.32 %r35 <- (1) %r34 + ret.32 %r35 + + +bfand: +.L12: + <entry-point> + setfval.32 %r38 <- 0.000000 + fcmpune.1 %r39 <- %arg1, %r38 + fcmpune.1 %r42 <- %arg2, %r38 + and.1 %r43 <- %r39, %r42 + setne.1 %r45 <- %r43, $0 + ret.1 %r45 + + +ifand: +.L14: + <entry-point> + setfval.32 %r48 <- 0.000000 + fcmpune.1 %r49 <- %arg1, %r48 + fcmpune.1 %r52 <- %arg2, %r48 + and.1 %r53 <- %r49, %r52 + zext.32 %r54 <- (1) %r53 + ret.32 %r54 + + * check-output-end */ diff --git a/validation/optim/bool-int-bool.c b/validation/optim/bool-int-bool.c new file mode 100644 index 00000000..de34a68b --- /dev/null +++ b/validation/optim/bool-int-bool.c @@ -0,0 +1,12 @@ +_Bool beq0(_Bool a) { return (a == 0); } +_Bool beq1(_Bool a) { return (a == 1); } +_Bool bne0(_Bool a) { return (a != 0); } +_Bool bne1(_Bool a) { return (a != 1); } + +/* + * check-name: bool - int - bool constants + * check-command: test-linearize -Wno-decl $file + * + * check-output-ignore + * check-output-excludes: cast\\. + */ diff --git a/validation/optim/bool-simplify.c b/validation/optim/bool-simplify.c index 5b3cf449..68aabb78 100644 --- a/validation/optim/bool-simplify.c +++ b/validation/optim/bool-simplify.c @@ -18,6 +18,17 @@ int or_1(int a) return a || 1; } +// try again but with something true but != 1 +int and_2(int a) +{ + return a && 2; +} + +int or_2(int a) +{ + return a || 2; +} + /* * check-name: bool-simplify * check-command: test-linearize -Wno-decl $file @@ -51,5 +62,19 @@ or_1: ret.32 $1 +and_2: +.L8: + <entry-point> + setne.1 %r26 <- %arg1, $0 + zext.32 %r29 <- (1) %r26 + ret.32 %r29 + + +or_2: +.L10: + <entry-point> + ret.32 $1 + + * check-output-end */ diff --git a/validation/optim/bool-simplify2.c b/validation/optim/bool-simplify2.c new file mode 100644 index 00000000..c94b4412 --- /dev/null +++ b/validation/optim/bool-simplify2.c @@ -0,0 +1,231 @@ +typedef unsigned int uint; +typedef _Bool bool; + +static uint ini(uint a) { return !a; } +static bool bni(uint a) { return !a; } +static uint ioii(uint a, uint b) { return a || b; } +static uint iaii(uint a, uint b) { return a && b; } +static bool boii(uint a, uint b) { return a || b; } +static bool baii(uint a, uint b) { return a && b; } +static uint ioiii(uint a, uint b, uint c) { return a || b || c; } +static uint iaiii(uint a, uint b, uint c) { return a && b && c; } +static bool boiii(uint a, uint b, uint c) { return a || b || c; } +static bool baiii(uint a, uint b, uint c) { return a && b && c; } + +static uint inb(bool a) { return !a; } +static bool bnb(bool a) { return !a; } +static uint iobb(bool a, bool b) { return a || b; } +static uint iabb(bool a, bool b) { return a && b; } +static bool bobb(bool a, bool b) { return a || b; } +static bool babb(bool a, bool b) { return a && b; } +static uint iobbb(bool a, bool b, bool c) { return a || b || c; } +static uint iabbb(bool a, bool b, bool c) { return a && b && c; } +static bool bobbb(bool a, bool b, bool c) { return a || b || c; } +static bool babbb(bool a, bool b, bool c) { return a && b && c; } + +/* + * check-name: bool-simplify2 + * check-command: test-linearize $file + * + * check-output-pattern(36): setne\\. + * check-output-pattern(4): seteq\\. + * check-output-pattern(8): zext\\. + * check-output-pattern(12): and + * check-output-pattern(12): or + * check-output-end + * + * check-output-start +ini: +.L0: + <entry-point> + seteq.32 %r2 <- %arg1, $0 + ret.32 %r2 + + +bni: +.L2: + <entry-point> + seteq.1 %r6 <- %arg1, $0 + ret.1 %r6 + + +ioii: +.L4: + <entry-point> + setne.1 %r9 <- %arg1, $0 + setne.1 %r11 <- %arg2, $0 + or.1 %r12 <- %r9, %r11 + zext.32 %r13 <- (1) %r12 + ret.32 %r13 + + +iaii: +.L6: + <entry-point> + setne.1 %r16 <- %arg1, $0 + setne.1 %r18 <- %arg2, $0 + and.1 %r19 <- %r16, %r18 + zext.32 %r20 <- (1) %r19 + ret.32 %r20 + + +boii: +.L8: + <entry-point> + setne.1 %r23 <- %arg1, $0 + setne.1 %r25 <- %arg2, $0 + or.1 %r26 <- %r23, %r25 + setne.1 %r28 <- %r26, $0 + ret.1 %r28 + + +baii: +.L10: + <entry-point> + setne.1 %r31 <- %arg1, $0 + setne.1 %r33 <- %arg2, $0 + and.1 %r34 <- %r31, %r33 + setne.1 %r36 <- %r34, $0 + ret.1 %r36 + + +ioiii: +.L12: + <entry-point> + setne.1 %r39 <- %arg1, $0 + setne.1 %r41 <- %arg2, $0 + or.1 %r42 <- %r39, %r41 + setne.1 %r44 <- %r42, $0 + setne.1 %r46 <- %arg3, $0 + or.1 %r47 <- %r44, %r46 + zext.32 %r48 <- (1) %r47 + ret.32 %r48 + + +iaiii: +.L14: + <entry-point> + setne.1 %r51 <- %arg1, $0 + setne.1 %r53 <- %arg2, $0 + and.1 %r54 <- %r51, %r53 + setne.1 %r56 <- %r54, $0 + setne.1 %r58 <- %arg3, $0 + and.1 %r59 <- %r56, %r58 + zext.32 %r60 <- (1) %r59 + ret.32 %r60 + + +boiii: +.L16: + <entry-point> + setne.1 %r63 <- %arg1, $0 + setne.1 %r65 <- %arg2, $0 + or.1 %r66 <- %r63, %r65 + setne.1 %r68 <- %r66, $0 + setne.1 %r70 <- %arg3, $0 + or.1 %r71 <- %r68, %r70 + setne.1 %r73 <- %r71, $0 + ret.1 %r73 + + +baiii: +.L18: + <entry-point> + setne.1 %r76 <- %arg1, $0 + setne.1 %r78 <- %arg2, $0 + and.1 %r79 <- %r76, %r78 + setne.1 %r81 <- %r79, $0 + setne.1 %r83 <- %arg3, $0 + and.1 %r84 <- %r81, %r83 + setne.1 %r86 <- %r84, $0 + ret.1 %r86 + + +inb: +.L20: + <entry-point> + seteq.32 %r89 <- %arg1, $0 + ret.32 %r89 + + +bnb: +.L22: + <entry-point> + seteq.1 %r93 <- %arg1, $0 + ret.1 %r93 + + +iobb: +.L24: + <entry-point> + or.1 %r97 <- %arg1, %arg2 + zext.32 %r98 <- (1) %r97 + ret.32 %r98 + + +iabb: +.L26: + <entry-point> + and.1 %r102 <- %arg1, %arg2 + zext.32 %r103 <- (1) %r102 + ret.32 %r103 + + +bobb: +.L28: + <entry-point> + or.1 %r107 <- %arg1, %arg2 + setne.1 %r109 <- %r107, $0 + ret.1 %r109 + + +babb: +.L30: + <entry-point> + and.1 %r113 <- %arg1, %arg2 + setne.1 %r115 <- %r113, $0 + ret.1 %r115 + + +iobbb: +.L32: + <entry-point> + or.1 %r119 <- %arg1, %arg2 + setne.1 %r121 <- %r119, $0 + or.1 %r123 <- %r121, %arg3 + zext.32 %r124 <- (1) %r123 + ret.32 %r124 + + +iabbb: +.L34: + <entry-point> + and.1 %r128 <- %arg1, %arg2 + setne.1 %r130 <- %r128, $0 + and.1 %r132 <- %r130, %arg3 + zext.32 %r133 <- (1) %r132 + ret.32 %r133 + + +bobbb: +.L36: + <entry-point> + or.1 %r137 <- %arg1, %arg2 + setne.1 %r139 <- %r137, $0 + or.1 %r141 <- %r139, %arg3 + setne.1 %r143 <- %r141, $0 + ret.1 %r143 + + +babbb: +.L38: + <entry-point> + and.1 %r147 <- %arg1, %arg2 + setne.1 %r149 <- %r147, $0 + and.1 %r151 <- %r149, %arg3 + setne.1 %r153 <- %r151, $0 + ret.1 %r153 + + + * check-output-end + */ |
