1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=ipsccp -S %s -o -| FileCheck %s
4 define i64 @test1(i32 %x) {
6 ; CHECK-NEXT: [[C:%.*]] = icmp sgt i32 [[X:%.*]], 0
7 ; CHECK-NEXT: br i1 [[C]], label [[TRUE:%.*]], label [[FALSE:%.*]]
9 ; CHECK-NEXT: [[EXT_1:%.*]] = sext i32 [[X]] to i64
10 ; CHECK-NEXT: ret i64 [[EXT_1]]
12 ; CHECK-NEXT: [[EXT_2:%.*]] = sext i32 [[X]] to i64
13 ; CHECK-NEXT: ret i64 [[EXT_2]]
15 %c = icmp sgt i32 %x, 0
16 br i1 %c, label %true, label %false
19 %ext.1 = sext i32 %x to i64
23 %ext.2 = sext i32 %x to i64
27 define i64 @test2(i32 %x) {
28 ; CHECK-LABEL: @test2(
29 ; CHECK-NEXT: [[C:%.*]] = icmp sge i32 [[X:%.*]], 0
30 ; CHECK-NEXT: br i1 [[C]], label [[TRUE:%.*]], label [[FALSE:%.*]]
32 ; CHECK-NEXT: [[EXT_1:%.*]] = sext i32 [[X]] to i64
33 ; CHECK-NEXT: ret i64 [[EXT_1]]
35 ; CHECK-NEXT: [[EXT_2:%.*]] = sext i32 [[X]] to i64
36 ; CHECK-NEXT: ret i64 [[EXT_2]]
38 %c = icmp sge i32 %x, 0
39 br i1 %c, label %true, label %false
42 %ext.1 = sext i32 %x to i64
46 %ext.2 = sext i32 %x to i64
51 define i64 @test3(i32 %x) {
52 ; CHECK-LABEL: @test3(
53 ; CHECK-NEXT: [[C:%.*]] = icmp sge i32 [[X:%.*]], -1
54 ; CHECK-NEXT: br i1 [[C]], label [[TRUE:%.*]], label [[FALSE:%.*]]
56 ; CHECK-NEXT: [[EXT_1:%.*]] = sext i32 [[X]] to i64
57 ; CHECK-NEXT: ret i64 [[EXT_1]]
59 ; CHECK-NEXT: [[EXT_2:%.*]] = sext i32 [[X]] to i64
60 ; CHECK-NEXT: ret i64 [[EXT_2]]
62 %c = icmp sge i32 %x, -1
63 br i1 %c, label %true, label %false
66 %ext.1 = sext i32 %x to i64
70 %ext.2 = sext i32 %x to i64
74 define i64 @test4_sext_op_can_be_undef(i1 %c.1, i1 %c.2) {
75 ; CHECK-LABEL: @test4_sext_op_can_be_undef(
76 ; CHECK-NEXT: br i1 [[C_1:%.*]], label [[TRUE_1:%.*]], label [[FALSE:%.*]]
78 ; CHECK-NEXT: br i1 [[C_2:%.*]], label [[TRUE_2:%.*]], label [[EXIT:%.*]]
80 ; CHECK-NEXT: br label [[EXIT]]
82 ; CHECK-NEXT: br label [[EXIT]]
84 ; CHECK-NEXT: [[P:%.*]] = phi i32 [ 0, [[TRUE_1]] ], [ 1, [[TRUE_2]] ], [ undef, [[FALSE]] ]
85 ; CHECK-NEXT: [[EXT:%.*]] = sext i32 [[P]] to i64
86 ; CHECK-NEXT: ret i64 [[EXT]]
88 br i1 %c.1, label %true.1, label %false
91 br i1 %c.2, label %true.2, label %exit
100 %p = phi i32 [ 0, %true.1 ], [ 1, %true.2], [ undef, %false ]
101 %ext = sext i32 %p to i64
105 define i64 @test5(i32 %x) {
106 ; CHECK-LABEL: @test5(
107 ; CHECK-NEXT: [[P:%.*]] = and i32 [[X:%.*]], 15
108 ; CHECK-NEXT: [[TMP1:%.*]] = zext i32 [[P]] to i64
109 ; CHECK-NEXT: ret i64 [[TMP1]]
112 %ext = sext i32 %p to i64
116 ; sext is constant folded before sext -> zext conversion.
117 define i64 @test6(i32 %x) {
118 ; CHECK-LABEL: @test6(
119 ; CHECK-NEXT: ret i64 10
121 %ext = sext i32 10 to i64
125 ; sext that can be converted to zext feeds another sext.
126 define i64 @test7(i16 %x) {
127 ; CHECK-LABEL: @test7(
128 ; CHECK-NEXT: [[P:%.*]] = and i16 [[X:%.*]], 15
129 ; CHECK-NEXT: [[TMP1:%.*]] = zext i16 [[P]] to i32
130 ; CHECK-NEXT: [[EXT_2:%.*]] = sext i32 [[TMP1]] to i64
131 ; CHECK-NEXT: ret i64 [[EXT_2]]
134 %ext.1 = sext i16 %p to i32
135 %ext.2 = sext i32 %ext.1 to i64