1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2 ; RUN: opt -passes=ipsccp -S %s | FileCheck %s
4 %struct.S = type { i32 }
8 ; CHECK-LABEL: define void @main() {
9 ; CHECK-NEXT: [[R:%.*]] = call i32 @f([[STRUCT_S:%.*]] { i32 100 })
10 ; CHECK-NEXT: call void @do_report(i32 123)
11 ; CHECK-NEXT: ret void
13 %r = call i32 @f(%struct.S { i32 100 })
14 call void @do_report(i32 %r)
18 declare void @do_report(i32)
20 define internal i32 @f(%struct.S %s.coerce) {
21 ; CHECK-LABEL: define internal i32 @f(
22 ; CHECK-SAME: [[STRUCT_S:%.*]] [[S_COERCE:%.*]]) {
23 ; CHECK-NEXT: [[ENTRY:.*]]:
24 ; CHECK-NEXT: [[CALL:%.*]] = call i8 @lsh(i8 1, i32 100)
25 ; CHECK-NEXT: br label %[[FOR_COND:.*]]
26 ; CHECK: [[FOR_COND]]:
27 ; CHECK-NEXT: [[I_0:%.*]] = phi i32 [ 0, %[[ENTRY]] ], [ [[INC:%.*]], %[[FOR_COND]] ]
28 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[I_0]], 1
29 ; CHECK-NEXT: [[INC]] = add nsw i32 [[I_0]], 1
30 ; CHECK-NEXT: br i1 [[CMP]], label %[[FOR_COND]], label %[[IF_END:.*]]
32 ; CHECK-NEXT: ret i32 poison
35 %ev = extractvalue %struct.S %s.coerce, 0
36 %call = call i8 @lsh(i8 1, i32 %ev)
37 %tobool = icmp ne i8 %call, 0
38 br i1 %tobool, label %for.cond, label %if.end
40 for.cond: ; preds = %for.cond, %if.then
41 %i.0 = phi i32 [ 0, %entry], [ %inc, %for.cond ]
42 %cmp = icmp slt i32 %i.0, 1
43 %inc = add nsw i32 %i.0, 1
44 br i1 %cmp, label %for.cond, label %if.end
46 if.end: ; preds = %for.cond, %entry
50 define internal i8 @lsh(i8 %l, i32 %r) {
51 ; CHECK-LABEL: define internal i8 @lsh(
52 ; CHECK-SAME: i8 [[L:%.*]], i32 [[R:%.*]]) {
53 ; CHECK-NEXT: [[ENTRY:.*:]]
54 ; CHECK-NEXT: ret i8 poison
57 %conv = sext i8 %l to i32
58 %cmp = icmp slt i32 %conv, 0
59 %shr = ashr i32 127, %r
60 %cmp4 = icmp sgt i32 %conv, %shr
61 %or.cond13 = or i1 %cmp, %cmp4
62 %cond = select i1 %or.cond13, i32 %conv, i32 0
63 %conv7 = trunc i32 %cond to i8