1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2 ; RUN: opt -S -passes=ipsccp < %s | FileCheck %s
4 ; Make sure that constant ranges including undef are propagated correctly.
6 define i8 @test_binop(i1 %cond, i8 %a) {
7 ; CHECK-LABEL: define i8 @test_binop(
8 ; CHECK-SAME: i1 [[COND:%.*]], i8 [[A:%.*]]) {
9 ; CHECK-NEXT: [[ENTRY:.*]]:
10 ; CHECK-NEXT: br i1 [[COND]], label %[[IF:.*]], label %[[JOIN:.*]]
12 ; CHECK-NEXT: [[A_EXT:%.*]] = zext i8 [[A]] to i16
13 ; CHECK-NEXT: br label %[[JOIN]]
15 ; CHECK-NEXT: [[PHI:%.*]] = phi i16 [ undef, %[[ENTRY]] ], [ [[A_EXT]], %[[IF]] ]
16 ; CHECK-NEXT: [[AND:%.*]] = and i16 [[PHI]], -1
17 ; CHECK-NEXT: [[TRUNC:%.*]] = trunc i16 [[AND]] to i8
18 ; CHECK-NEXT: ret i8 [[TRUNC]]
21 br i1 %cond, label %if, label %join
24 %a.ext = zext i8 %a to i16
28 %phi = phi i16 [ undef, %entry ], [ %a.ext, %if ]
29 %and = and i16 %phi, u0x0000ffff
30 %trunc = trunc i16 %and to i8
34 define i8 @test_cast(i1 %cond, i8 %a) {
35 ; CHECK-LABEL: define i8 @test_cast(
36 ; CHECK-SAME: i1 [[COND:%.*]], i8 [[A:%.*]]) {
37 ; CHECK-NEXT: [[ENTRY:.*]]:
38 ; CHECK-NEXT: br i1 [[COND]], label %[[IF:.*]], label %[[JOIN:.*]]
40 ; CHECK-NEXT: [[A_EXT:%.*]] = zext i8 [[A]] to i16
41 ; CHECK-NEXT: br label %[[JOIN]]
43 ; CHECK-NEXT: [[PHI:%.*]] = phi i16 [ undef, %[[ENTRY]] ], [ [[A_EXT]], %[[IF]] ]
44 ; CHECK-NEXT: [[ZEXT:%.*]] = zext i16 [[PHI]] to i32
45 ; CHECK-NEXT: [[TRUNC:%.*]] = trunc i32 [[ZEXT]] to i8
46 ; CHECK-NEXT: ret i8 [[TRUNC]]
49 br i1 %cond, label %if, label %join
52 %a.ext = zext i8 %a to i16
56 %phi = phi i16 [ undef, %entry ], [ %a.ext, %if ]
57 %zext = zext i16 %phi to i32
58 %trunc = trunc i32 %zext to i8
62 define i8 @test_intrin(i1 %cond, i8 %a) {
63 ; CHECK-LABEL: define i8 @test_intrin(
64 ; CHECK-SAME: i1 [[COND:%.*]], i8 [[A:%.*]]) {
65 ; CHECK-NEXT: [[ENTRY:.*]]:
66 ; CHECK-NEXT: br i1 [[COND]], label %[[IF:.*]], label %[[JOIN:.*]]
68 ; CHECK-NEXT: [[A_EXT:%.*]] = zext i8 [[A]] to i16
69 ; CHECK-NEXT: br label %[[JOIN]]
71 ; CHECK-NEXT: [[PHI:%.*]] = phi i16 [ undef, %[[ENTRY]] ], [ [[A_EXT]], %[[IF]] ]
72 ; CHECK-NEXT: [[UMAX:%.*]] = call i16 @llvm.umax.i16(i16 [[PHI]], i16 42)
73 ; CHECK-NEXT: [[TRUNC:%.*]] = trunc i16 [[UMAX]] to i8
74 ; CHECK-NEXT: ret i8 [[TRUNC]]
77 br i1 %cond, label %if, label %join
80 %a.ext = zext i8 %a to i16
84 %phi = phi i16 [ undef, %entry ], [ %a.ext, %if ]
85 %umax = call i16 @llvm.umax(i16 %phi, i16 42)
86 %trunc = trunc i16 %umax to i8
90 define i9 @test_with_overflow(i1 %cond, i8 %a) {
91 ; CHECK-LABEL: define i9 @test_with_overflow(
92 ; CHECK-SAME: i1 [[COND:%.*]], i8 [[A:%.*]]) {
93 ; CHECK-NEXT: [[ENTRY:.*]]:
94 ; CHECK-NEXT: br i1 [[COND]], label %[[IF:.*]], label %[[JOIN:.*]]
96 ; CHECK-NEXT: [[A_EXT:%.*]] = zext i8 [[A]] to i16
97 ; CHECK-NEXT: br label %[[JOIN]]
99 ; CHECK-NEXT: [[PHI:%.*]] = phi i16 [ undef, %[[ENTRY]] ], [ [[A_EXT]], %[[IF]] ]
100 ; CHECK-NEXT: [[WO:%.*]] = call { i16, i1 } @llvm.uadd.with.overflow.i16(i16 [[PHI]], i16 1)
101 ; CHECK-NEXT: [[ADD:%.*]] = extractvalue { i16, i1 } [[WO]], 0
102 ; CHECK-NEXT: [[TRUNC:%.*]] = trunc i16 [[ADD]] to i9
103 ; CHECK-NEXT: ret i9 [[TRUNC]]
106 br i1 %cond, label %if, label %join
109 %a.ext = zext i8 %a to i16
113 %phi = phi i16 [ undef, %entry ], [ %a.ext, %if ]
114 %wo = call {i16, i1} @llvm.uadd.with.overflow(i16 %phi, i16 1)
115 %add = extractvalue {i16, i1} %wo, 0
116 %trunc = trunc i16 %add to i9