1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -newgvn -S | FileCheck %s
3 ; RUN: opt < %s -newgvn -jump-threading -S | FileCheck --check-prefix=CHECK-JT %s
5 define signext i32 @testBI(i32 signext %v) {
6 ; Test with std::pair<bool, int>
7 ; based on the following C++ code
8 ; std::pair<bool, int> callee(int v) {
10 ; if (a) return std::make_pair(true, dummy(a));
11 ; else return std::make_pair(v < 0, v);
14 ; std::pair<bool, int> rc = callee(v);
15 ; if (rc.first) dummy(0);
18 ; CHECK-LABEL: @testBI(
19 ; CHECK: _ZL6calleei.exit:
20 ; CHECK: [[PHIOFOPS:%.*]] = phi i64 [ 1, %if.then.i ], [ {{%.*}}, %if.else.i ]
21 ; CHECK: [[TOBOOL:%.*]] = icmp eq i64 [[PHIOFOPS]], 0
23 ; CHECK-JT-LABEL: @testBI(
24 ; CHECK-JT: _ZL6calleei.exit.thread:
28 %call.i = call signext i32 @dummy(i32 signext %v)
29 %tobool.i = icmp eq i32 %call.i, 0
30 br i1 %tobool.i, label %if.else.i, label %if.then.i
32 if.then.i: ; preds = %entry
33 %call2.i = call signext i32 @dummy(i32 signext %call.i)
34 %retval.sroa.22.0.insert.ext.i.i = zext i32 %call2.i to i64
35 %retval.sroa.22.0.insert.shift.i.i = shl nuw i64 %retval.sroa.22.0.insert.ext.i.i, 32
36 %retval.sroa.0.0.insert.insert.i.i = or i64 %retval.sroa.22.0.insert.shift.i.i, 1
37 br label %_ZL6calleei.exit
39 if.else.i: ; preds = %entry
40 %.lobit.i = lshr i32 %v, 31
41 %0 = zext i32 %.lobit.i to i64
42 %retval.sroa.22.0.insert.ext.i8.i = zext i32 %v to i64
43 %retval.sroa.22.0.insert.shift.i9.i = shl nuw i64 %retval.sroa.22.0.insert.ext.i8.i, 32
44 %retval.sroa.0.0.insert.insert.i11.i = or i64 %retval.sroa.22.0.insert.shift.i9.i, %0
45 br label %_ZL6calleei.exit
47 _ZL6calleei.exit: ; preds = %if.then.i, %if.else.i
48 %retval.sroa.0.0.i = phi i64 [ %retval.sroa.0.0.insert.insert.i.i, %if.then.i ], [ %retval.sroa.0.0.insert.insert.i11.i, %if.else.i ]
49 %rc.sroa.43.0.extract.shift = lshr i64 %retval.sroa.0.0.i, 32
50 %rc.sroa.43.0.extract.trunc = trunc i64 %rc.sroa.43.0.extract.shift to i32
51 %1 = and i64 %retval.sroa.0.0.i, 1
52 %tobool = icmp eq i64 %1, 0
53 br i1 %tobool, label %if.end, label %if.then
55 if.then: ; preds = %_ZL6calleei.exit
56 %call1 = call signext i32 @dummy(i32 signext 0)
59 if.end: ; preds = %_ZL6calleei.exit, %if.then
60 ret i32 %rc.sroa.43.0.extract.trunc
64 define signext i32 @testIB(i32 signext %v) {
65 ; Test with std::pair<int, bool>
66 ; based on the following C++ code
67 ; std::pair<int, bool> callee(int v) {
69 ; if (a) return std::make_pair(dummy(v), true);
70 ; else return std::make_pair(v, v < 0);
73 ; std::pair<int, bool> rc = callee(v);
74 ; if (rc.second) dummy(0);
77 ; CHECK-LABEL: @testIB(
78 ; CHECK: _ZL6calleei.exit:
79 ; CHECK: [[PHIOFOPS:%.*]] = phi i64 [ 4294967296, %if.then.i ], [ {{%.*}}, %if.else.i ]
80 ; CHECK: [[TOBOOL:%.*]] = icmp eq i64 [[PHIOFOPS]], 0
82 ; CHECK-JT-LABEL: @testIB(
83 ; CHECK-JT: _ZL6calleei.exit.thread:
87 %call.i = call signext i32 @dummy(i32 signext %v)
88 %tobool.i = icmp eq i32 %call.i, 0
89 br i1 %tobool.i, label %if.else.i, label %if.then.i
91 if.then.i: ; preds = %entry
92 %call1.i = call signext i32 @dummy(i32 signext %v)
93 %retval.sroa.0.0.insert.ext.i.i = zext i32 %call1.i to i64
94 %retval.sroa.0.0.insert.insert.i.i = or i64 %retval.sroa.0.0.insert.ext.i.i, 4294967296
95 br label %_ZL6calleei.exit
97 if.else.i: ; preds = %entry
98 %.lobit.i = lshr i32 %v, 31
99 %0 = zext i32 %.lobit.i to i64
100 %retval.sroa.2.0.insert.shift.i8.i = shl nuw nsw i64 %0, 32
101 %retval.sroa.0.0.insert.ext.i9.i = zext i32 %v to i64
102 %retval.sroa.0.0.insert.insert.i10.i = or i64 %retval.sroa.2.0.insert.shift.i8.i, %retval.sroa.0.0.insert.ext.i9.i
103 br label %_ZL6calleei.exit
105 _ZL6calleei.exit: ; preds = %if.then.i, %if.else.i
106 %retval.sroa.0.0.i = phi i64 [ %retval.sroa.0.0.insert.insert.i.i, %if.then.i ], [ %retval.sroa.0.0.insert.insert.i10.i, %if.else.i ]
107 %rc.sroa.0.0.extract.trunc = trunc i64 %retval.sroa.0.0.i to i32
108 %1 = and i64 %retval.sroa.0.0.i, 4294967296
109 %tobool = icmp eq i64 %1, 0
110 br i1 %tobool, label %if.end, label %if.then
112 if.then: ; preds = %_ZL6calleei.exit
113 %call1 = call signext i32 @dummy(i32 signext 0)
116 if.end: ; preds = %_ZL6calleei.exit, %if.then
117 ret i32 %rc.sroa.0.0.extract.trunc
120 declare signext i32 @dummy(i32 signext %v)