1 ; RUN: opt < %s -instcombine -S | FileCheck %s
3 ; This test makes sure that InstCombine does not replace the sequence of
4 ; xor/sub instruction followed by cmp instruction into a single cmp instruction
5 ; if there is more than one use of xor/sub.
7 define zeroext i1 @test1(i32 %lhs, i32 %rhs) {
9 ; CHECK-NEXT: %xor = xor i32 %lhs, 5
10 ; CHECK-NEXT: %cmp1 = icmp eq i32 %xor, 10
12 %xor = xor i32 %lhs, 5
13 %cmp1 = icmp eq i32 %xor, 10
14 %cmp2 = icmp eq i32 %xor, %rhs
15 %sel = or i1 %cmp1, %cmp2
19 define zeroext i1 @test2(i32 %lhs, i32 %rhs) {
20 ; CHECK-LABEL: @test2(
21 ; CHECK-NEXT: %xor = xor i32 %lhs, %rhs
22 ; CHECK-NEXT: %cmp1 = icmp eq i32 %xor, 0
24 %xor = xor i32 %lhs, %rhs
25 %cmp1 = icmp eq i32 %xor, 0
26 %cmp2 = icmp eq i32 %xor, 32
27 %sel = xor i1 %cmp1, %cmp2
31 define zeroext i1 @test3(i32 %lhs, i32 %rhs) {
32 ; CHECK-LABEL: @test3(
33 ; CHECK-NEXT: %sub = sub nsw i32 %lhs, %rhs
34 ; CHECK-NEXT: %cmp1 = icmp eq i32 %sub, 0
36 %sub = sub nsw i32 %lhs, %rhs
37 %cmp1 = icmp eq i32 %sub, 0
38 %cmp2 = icmp eq i32 %sub, 31
39 %sel = or i1 %cmp1, %cmp2