annotate test/Transforms/InstCombine/zext-or-icmp.ll @ 121:803732b1fca8

LLVM 5.0
author kono
date Fri, 27 Oct 2017 17:07:41 +0900
parents 1172e4bd9c6f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 95
diff changeset
1 ; RUN: opt < %s -instcombine -S | FileCheck %s
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 95
diff changeset
3 ; Remove an icmp by using its operand in the subsequent logic directly.
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 95
diff changeset
5 define i8 @zext_or_icmp_icmp(i8 %a, i8 %b) {
1172e4bd9c6f update 4.0.0
mir3636
parents: 95
diff changeset
6 %mask = and i8 %a, 1
1172e4bd9c6f update 4.0.0
mir3636
parents: 95
diff changeset
7 %toBool1 = icmp eq i8 %mask, 0
1172e4bd9c6f update 4.0.0
mir3636
parents: 95
diff changeset
8 %toBool2 = icmp eq i8 %b, 0
1172e4bd9c6f update 4.0.0
mir3636
parents: 95
diff changeset
9 %bothCond = or i1 %toBool1, %toBool2
1172e4bd9c6f update 4.0.0
mir3636
parents: 95
diff changeset
10 %zext = zext i1 %bothCond to i8
1172e4bd9c6f update 4.0.0
mir3636
parents: 95
diff changeset
11 ret i8 %zext
1172e4bd9c6f update 4.0.0
mir3636
parents: 95
diff changeset
12
1172e4bd9c6f update 4.0.0
mir3636
parents: 95
diff changeset
13 ; CHECK-LABEL: zext_or_icmp_icmp(
1172e4bd9c6f update 4.0.0
mir3636
parents: 95
diff changeset
14 ; CHECK-NEXT: %mask = and i8 %a, 1
1172e4bd9c6f update 4.0.0
mir3636
parents: 95
diff changeset
15 ; CHECK-NEXT: %toBool2 = icmp eq i8 %b, 0
1172e4bd9c6f update 4.0.0
mir3636
parents: 95
diff changeset
16 ; CHECK-NEXT: %toBool22 = zext i1 %toBool2 to i8
1172e4bd9c6f update 4.0.0
mir3636
parents: 95
diff changeset
17 ; CHECK-NEXT: %1 = xor i8 %mask, 1
1172e4bd9c6f update 4.0.0
mir3636
parents: 95
diff changeset
18 ; CHECK-NEXT: %zext = or i8 %1, %toBool22
1172e4bd9c6f update 4.0.0
mir3636
parents: 95
diff changeset
19 ; CHECK-NEXT: ret i8 %zext
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 }
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 95
diff changeset
21
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
22 ; Here, widening the or from i1 to i32 and removing one of the icmps would
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
23 ; widen an undef value (created by the out-of-range shift), increasing the
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
24 ; range of valid values for the return, so we can't do it.
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
25 define i32 @dont_widen_undef() {
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
26 entry:
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
27 br label %block2
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
28
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
29 block1:
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
30 br label %block2
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
31
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
32 block2:
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
33 %m.011 = phi i32 [ 33, %entry ], [ 0, %block1 ]
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
34 %cmp.i = icmp ugt i32 %m.011, 1
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
35 %m.1.op = lshr i32 1, %m.011
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
36 %sext.mask = and i32 %m.1.op, 65535
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
37 %cmp115 = icmp ne i32 %sext.mask, 0
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
38 %cmp1 = or i1 %cmp.i, %cmp115
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
39 %conv2 = zext i1 %cmp1 to i32
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
40 ret i32 %conv2
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
41
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
42 ; CHECK-LABEL: dont_widen_undef(
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
43 ; CHECK: %m.011 = phi i32 [ 33, %entry ], [ 0, %block1 ]
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
44 ; CHECK-NEXT: %cmp.i = icmp ugt i32 %m.011, 1
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
45 ; CHECK-NEXT: %m.1.op = lshr i32 1, %m.011
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
46 ; CHECK-NEXT: %sext.mask = and i32 %m.1.op, 65535
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
47 ; CHECK-NEXT: %cmp115 = icmp ne i32 %sext.mask, 0
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
48 ; CHECK-NEXT: %cmp1 = or i1 %cmp.i, %cmp115
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
49 ; CHECK-NEXT: %conv2 = zext i1 %cmp1 to i32
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
50 ; CHECK-NEXT: ret i32 %conv2
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
51 }