1 ; RUN: opt %s -instcombine -S | FileCheck %s
4 ; TODO: This should also optimize down.
5 ;define i32 @test1(i32 %a, i32 %b) nounwind readnone {
7 ; %0 = icmp sgt i32 %a, -1 ; <i1> [#uses=1]
8 ; %1 = icmp slt i32 %b, 0 ; <i1> [#uses=1]
9 ; %2 = xor i1 %1, %0 ; <i1> [#uses=1]
10 ; %3 = zext i1 %2 to i32 ; <i32> [#uses=1]
14 ; TODO: This optimizes partially but not all the way.
15 ;define i32 @test2(i32 %a, i32 %b) nounwind readnone {
17 ; %0 = and i32 %a, 8 ;<i32> [#uses=1]
18 ; %1 = and i32 %b, 8 ;<i32> [#uses=1]
19 ; %2 = icmp eq i32 %0, %1 ;<i1> [#uses=1]
20 ; %3 = zext i1 %2 to i32 ;<i32> [#uses=1]
24 define i32 @test3(i32 %a, i32 %b) nounwind readnone {
27 ; CHECK: xor i32 %a, %b
28 ; CHECK: lshr i32 %0, 31
29 ; CHECK: xor i32 %1, 1
30 %0 = lshr i32 %a, 31 ; <i32> [#uses=1]
31 %1 = lshr i32 %b, 31 ; <i32> [#uses=1]
32 %2 = icmp eq i32 %0, %1 ; <i1> [#uses=1]
33 %3 = zext i1 %2 to i32 ; <i32> [#uses=1]
40 ; Variation on @test3: checking the 2nd bit in a situation where the 5th bit
42 define i32 @test3i(i32 %a, i32 %b) nounwind readnone {
45 ; CHECK: xor i32 %a, %b
46 ; CHECK: lshr i32 %0, 31
47 ; CHECK: xor i32 %1, 1
48 %0 = lshr i32 %a, 29 ; <i32> [#uses=1]
49 %1 = lshr i32 %b, 29 ; <i32> [#uses=1]
52 %4 = icmp eq i32 %2, %3 ; <i1> [#uses=1]
53 %5 = zext i1 %4 to i32 ; <i32> [#uses=1]