; This test makes sure that these instructions are properly eliminated.
;
-
-; RUN: as < %s | opt -instcombine | dis | grep-not set
+; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine -disable-output &&
+; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | not grep icmp
%X = uninitialized global int
ret bool %C
}
-; These instructions can be turned into cast-to-bool
-bool %test15(sbyte %A, short %A, int %A, long %A) {
- %B1 = setne sbyte %A, 0
- %B2 = seteq short %A, 0
- %B3 = setne int %A, 0
- %B4 = seteq long %A, 0
- %C1 = or bool %B1, %B2
- %C2 = or bool %B3, %B4
- %D = or bool %C1, %C2
- ret bool %D
+bool %test16(uint %A) {
+ %B = and uint %A, 5
+ %C = seteq uint %B, 8 ; Is never true
+ ret bool %C
+}
+
+bool %test17(ubyte %A) {
+ %B = or ubyte %A, 1
+ %C = seteq ubyte %B, 2 ; Always false
+ ret bool %C
+}
+
+bool %test18(bool %C, int %a) {
+entry:
+ br bool %C, label %endif, label %else
+
+else:
+ br label %endif
+
+endif:
+ %b.0 = phi int [ 0, %entry ], [ 1, %else ]
+ %tmp.4 = setlt int %b.0, 123
+ ret bool %tmp.4
+}
+
+bool %test19(bool %A, bool %B) {
+ %a = cast bool %A to int
+ %b = cast bool %B to int
+ %C = seteq int %a, %b
+ ret bool %C
+}
+
+uint %test20(uint %A) {
+ %B = and uint %A, 1
+ %C = setne uint %B, 0
+ %D = cast bool %C to uint
+ ret uint %D
+}
+
+int %test21(int %a) {
+ %tmp.6 = and int %a, 4
+ %not.tmp.7 = setne int %tmp.6, 0
+ %retval = cast bool %not.tmp.7 to int
+ ret int %retval
+}
+
+bool %test22(uint %A, int %X) {
+ %B = and uint %A, 100663295
+ %C = setlt uint %B, 268435456
+ %Y = and int %X, 7
+ %Z = setgt int %Y, -1
+ %R = or bool %C, %Z
+ ret bool %R
+}
+
+int %test23(int %a) {
+ %tmp.1 = and int %a, 1
+ %tmp.2 = seteq int %tmp.1, 0
+ %tmp.3 = cast bool %tmp.2 to int ;; xor tmp1, 1
+ ret int %tmp.3
}
+
+int %test24(uint %a) {
+ %tmp1 = and uint %a, 4
+ %tmp.1 = shr uint %tmp1, ubyte 2
+ %tmp.2 = seteq uint %tmp.1, 0
+ %tmp.3 = cast bool %tmp.2 to int ;; xor tmp1, 1
+ ret int %tmp.3
+}
+