X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=test%2FTransforms%2FInstCombine%2Fxor2.ll;h=d153e035c8996abc08de1826513672cd5e78a070;hb=b55dcfe47fbbcfc1dccd07cb27c02b9a86533d05;hp=89f00bd684757c12135f4cc6765376acdd0d733b;hpb=26c5663283f89f1624304723ebe8c25d253463a3;p=oota-llvm.git diff --git a/test/Transforms/InstCombine/xor2.ll b/test/Transforms/InstCombine/xor2.ll index 89f00bd6847..d153e035c89 100644 --- a/test/Transforms/InstCombine/xor2.ll +++ b/test/Transforms/InstCombine/xor2.ll @@ -4,7 +4,7 @@ ; PR1253 define i1 @test0(i32 %A) { -; CHECK: @test0 +; CHECK-LABEL: @test0( ; CHECK: %C = icmp slt i32 %A, 0 %B = xor i32 %A, -2147483648 %C = icmp sgt i32 %B, -1 @@ -12,7 +12,7 @@ define i1 @test0(i32 %A) { } define i1 @test1(i32 %A) { -; CHECK: @test1 +; CHECK-LABEL: @test1( ; CHECK: %C = icmp slt i32 %A, 0 %B = xor i32 %A, 12345 %C = icmp slt i32 %B, 0 @@ -21,7 +21,7 @@ define i1 @test1(i32 %A) { ; PR1014 define i32 @test2(i32 %tmp1) { -; CHECK: @test2 +; CHECK-LABEL: @test2( ; CHECK-NEXT: and i32 %tmp1, 32 ; CHECK-NEXT: or i32 %ovm, 8 ; CHECK-NEXT: ret i32 @@ -32,7 +32,7 @@ define i32 @test2(i32 %tmp1) { } define i32 @test3(i32 %tmp1) { -; CHECK: @test3 +; CHECK-LABEL: @test3( ; CHECK-NEXT: and i32 %tmp1, 32 ; CHECK-NEXT: or i32 %ovm, 8 ; CHECK-NEXT: ret i32 @@ -47,7 +47,38 @@ define i32 @test4(i32 %A, i32 %B) { %2 = ashr i32 %1, %B %3 = xor i32 %2, -1 ret i32 %3 -; CHECK: @test4 +; CHECK-LABEL: @test4( ; CHECK: %1 = ashr i32 %A, %B ; CHECK: ret i32 %1 } + +; defect-2 in rdar://12329730 +; (X^C1) >> C2) ^ C3 -> (X>>C2) ^ ((C1>>C2)^C3) +; where the "X" has more than one use +define i32 @test5(i32 %val1) { +test5: + %xor = xor i32 %val1, 1234 + %shr = lshr i32 %xor, 8 + %xor1 = xor i32 %shr, 1 + %add = add i32 %xor1, %xor + ret i32 %add +; CHECK-LABEL: @test5( +; CHECK: lshr i32 %val1, 8 +; CHECK: ret +} + +; defect-1 in rdar://12329730 +; Simplify (X^Y) -> X or Y in the user's context if we know that +; only bits from X or Y are demanded. +; e.g. the "x ^ 1234" can be optimized into x in the context of "t >> 16". +; Put in other word, t >> 16 -> x >> 16. +; unsigned foo(unsigned x) { unsigned t = x ^ 1234; ; return (t >> 16) + t;} +define i32 @test6(i32 %x) { + %xor = xor i32 %x, 1234 + %shr = lshr i32 %xor, 16 + %add = add i32 %shr, %xor + ret i32 %add +; CHECK-LABEL: @test6( +; CHECK: lshr i32 %x, 16 +; CHECK: ret +}