1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --scrub-attributes 2; RUN: opt -attributor -attributor-disable=false -S < %s | FileCheck %s --check-prefixes=CHECK,OLD_PM,MODULE_OLD_PM 3; RUN: opt -passes=attributor -attributor-disable=false -S < %s | FileCheck %s --check-prefixes=CHECK,NEW_PM,MODULE_NEW_PM 4; RUN: opt -attributor-cgscc -attributor-disable=false -S < %s | FileCheck %s --check-prefixes=CHECK,CGSCC_OLD_PM 5; RUN: opt -passes=attributor-cgscc -attributor-disable=false -S < %s | FileCheck %s --check-prefixes=CHECK,CGSCC_NEW_PM 6 7; FIXME: CGSCC is not looking at callees and calleers even though it could be allowed. 8 9define i32 @test0(i32* %p) { 10; CHECK-LABEL: define {{[^@]+}}@test0 11; CHECK-SAME: (i32* nocapture nofree nonnull readonly align 4 dereferenceable(4) [[P:%.*]]) 12; CHECK-NEXT: [[A:%.*]] = load i32, i32* [[P]], align 4, !range !0 13; CHECK-NEXT: ret i32 [[A]] 14; 15 %a = load i32, i32* %p, !range !0 16 ret i32 %a 17} 18 19define i32 @test0-range-check(i32* %p) { 20; 21; OLD_PM-LABEL: define {{[^@]+}}@test0-range-check 22; OLD_PM-SAME: (i32* nocapture nofree readonly align 4 [[P:%.*]]) 23; OLD_PM-NEXT: [[A:%.*]] = tail call i32 @test0(i32* nocapture nofree readonly align 4 [[P]]) #{{[0-9]+}}, !range !0 24; OLD_PM-NEXT: ret i32 [[A]] 25; 26; NEW_PM-LABEL: define {{[^@]+}}@test0-range-check 27; NEW_PM-SAME: (i32* nocapture nofree readonly align 4 [[P:%.*]]) 28; NEW_PM-NEXT: [[A:%.*]] = tail call i32 @test0(i32* nocapture nofree readonly align 4 [[P]]) #{{[0-9]+}}, !range !0 29; NEW_PM-NEXT: ret i32 [[A]] 30; 31; CGSCC_OLD_PM-LABEL: define {{[^@]+}}@test0-range-check 32; CGSCC_OLD_PM-SAME: (i32* nocapture nofree nonnull readonly align 4 dereferenceable(4) [[P:%.*]]) 33; CGSCC_OLD_PM-NEXT: [[A:%.*]] = tail call i32 @test0(i32* nocapture nofree nonnull readonly align 4 dereferenceable(4) [[P]]) 34; CGSCC_OLD_PM-NEXT: ret i32 [[A]] 35; 36; CGSCC_NEW_PM-LABEL: define {{[^@]+}}@test0-range-check 37; CGSCC_NEW_PM-SAME: (i32* nocapture nofree nonnull readonly align 4 dereferenceable(4) [[P:%.*]]) 38; CGSCC_NEW_PM-NEXT: [[A:%.*]] = tail call i32 @test0(i32* nocapture nofree nonnull readonly align 4 dereferenceable(4) [[P]]) 39; CGSCC_NEW_PM-NEXT: ret i32 [[A]] 40; 41 %a = tail call i32 @test0(i32* %p) 42 ret i32 %a 43} 44 45declare void @use3-dummy(i1, i1, i1) 46define void @use3(i1, i1, i1) { 47; CHECK-LABEL: define {{[^@]+}}@use3 48; CHECK-SAME: (i1 [[TMP0:%.*]], i1 [[TMP1:%.*]], i1 [[TMP2:%.*]]) 49; CHECK-NEXT: tail call void @use3-dummy(i1 [[TMP0]], i1 [[TMP1]], i1 [[TMP2]]) 50; CHECK-NEXT: ret void 51; 52 tail call void @use3-dummy(i1 %0, i1 %1, i1 %2) 53 ret void 54} 55 56; TEST0 icmp test 57define void @test0-icmp-check(i32* %p){ 58; OLD_PM-LABEL: define {{[^@]+}}@test0-icmp-check 59; OLD_PM-SAME: (i32* nocapture nofree readonly align 4 [[P:%.*]]) 60; OLD_PM-NEXT: [[RET:%.*]] = tail call i32 @test0(i32* nocapture nofree readonly align 4 [[P]]) #{{[0-9]+}}, !range !0 61; OLD_PM-NEXT: [[CMP_EQ_2:%.*]] = icmp eq i32 [[RET]], 9 62; OLD_PM-NEXT: [[CMP_EQ_3:%.*]] = icmp eq i32 [[RET]], 8 63; OLD_PM-NEXT: [[CMP_EQ_4:%.*]] = icmp eq i32 [[RET]], 1 64; OLD_PM-NEXT: [[CMP_EQ_5:%.*]] = icmp eq i32 [[RET]], 0 65; OLD_PM-NEXT: tail call void @use3(i1 false, i1 [[CMP_EQ_2]], i1 [[CMP_EQ_3]]) 66; OLD_PM-NEXT: tail call void @use3(i1 [[CMP_EQ_4]], i1 [[CMP_EQ_5]], i1 false) 67; OLD_PM-NEXT: [[CMP_NE_2:%.*]] = icmp ne i32 [[RET]], 9 68; OLD_PM-NEXT: [[CMP_NE_3:%.*]] = icmp ne i32 [[RET]], 8 69; OLD_PM-NEXT: [[CMP_NE_4:%.*]] = icmp ne i32 [[RET]], 1 70; OLD_PM-NEXT: [[CMP_NE_5:%.*]] = icmp ne i32 [[RET]], 0 71; OLD_PM-NEXT: tail call void @use3(i1 true, i1 [[CMP_NE_2]], i1 [[CMP_NE_3]]) 72; OLD_PM-NEXT: tail call void @use3(i1 [[CMP_NE_4]], i1 [[CMP_NE_5]], i1 true) 73; OLD_PM-NEXT: [[CMP_UGT_3:%.*]] = icmp ugt i32 [[RET]], 8 74; OLD_PM-NEXT: [[CMP_UGT_4:%.*]] = icmp ugt i32 [[RET]], 1 75; OLD_PM-NEXT: [[CMP_UGT_5:%.*]] = icmp ugt i32 [[RET]], 0 76; OLD_PM-NEXT: tail call void @use3(i1 false, i1 false, i1 [[CMP_UGT_3]]) 77; OLD_PM-NEXT: tail call void @use3(i1 [[CMP_UGT_4]], i1 [[CMP_UGT_5]], i1 false) 78; OLD_PM-NEXT: [[CMP_UGE_2:%.*]] = icmp uge i32 [[RET]], 9 79; OLD_PM-NEXT: [[CMP_UGE_3:%.*]] = icmp uge i32 [[RET]], 8 80; OLD_PM-NEXT: [[CMP_UGE_4:%.*]] = icmp uge i32 [[RET]], 1 81; OLD_PM-NEXT: tail call void @use3(i1 false, i1 [[CMP_UGE_2]], i1 [[CMP_UGE_3]]) 82; OLD_PM-NEXT: tail call void @use3(i1 [[CMP_UGE_4]], i1 true, i1 false) 83; OLD_PM-NEXT: [[CMP_SGT_3:%.*]] = icmp sgt i32 [[RET]], 8 84; OLD_PM-NEXT: [[CMP_SGT_4:%.*]] = icmp sgt i32 [[RET]], 1 85; OLD_PM-NEXT: [[CMP_SGT_5:%.*]] = icmp sgt i32 [[RET]], 0 86; OLD_PM-NEXT: tail call void @use3(i1 false, i1 false, i1 [[CMP_SGT_3]]) 87; OLD_PM-NEXT: tail call void @use3(i1 [[CMP_SGT_4]], i1 [[CMP_SGT_5]], i1 true) 88; OLD_PM-NEXT: [[CMP_GTE_2:%.*]] = icmp sge i32 [[RET]], 9 89; OLD_PM-NEXT: [[CMP_GTE_3:%.*]] = icmp sge i32 [[RET]], 8 90; OLD_PM-NEXT: [[CMP_GTE_4:%.*]] = icmp sge i32 [[RET]], 1 91; OLD_PM-NEXT: tail call void @use3(i1 false, i1 [[CMP_GTE_2]], i1 [[CMP_GTE_3]]) 92; OLD_PM-NEXT: tail call void @use3(i1 [[CMP_GTE_4]], i1 true, i1 true) 93; OLD_PM-NEXT: [[CMP_SLT_2:%.*]] = icmp slt i32 [[RET]], 9 94; OLD_PM-NEXT: [[CMP_SLT_3:%.*]] = icmp slt i32 [[RET]], 8 95; OLD_PM-NEXT: [[CMP_SLT_4:%.*]] = icmp slt i32 [[RET]], 1 96; OLD_PM-NEXT: tail call void @use3(i1 true, i1 [[CMP_SLT_2]], i1 [[CMP_SLT_3]]) 97; OLD_PM-NEXT: tail call void @use3(i1 [[CMP_SLT_4]], i1 false, i1 false) 98; OLD_PM-NEXT: [[CMP_LTE_3:%.*]] = icmp sle i32 [[RET]], 8 99; OLD_PM-NEXT: [[CMP_LTE_4:%.*]] = icmp sle i32 [[RET]], 1 100; OLD_PM-NEXT: [[CMP_LTE_5:%.*]] = icmp sle i32 [[RET]], 0 101; OLD_PM-NEXT: tail call void @use3(i1 true, i1 true, i1 [[CMP_LTE_3]]) 102; OLD_PM-NEXT: tail call void @use3(i1 [[CMP_LTE_4]], i1 [[CMP_LTE_5]], i1 false) 103; OLD_PM-NEXT: ret void 104; 105; NEW_PM-LABEL: define {{[^@]+}}@test0-icmp-check 106; NEW_PM-SAME: (i32* nocapture nofree readonly align 4 [[P:%.*]]) 107; NEW_PM-NEXT: [[RET:%.*]] = tail call i32 @test0(i32* nocapture nofree readonly align 4 [[P]]) #{{[0-9]+}}, !range !0 108; NEW_PM-NEXT: [[CMP_EQ_2:%.*]] = icmp eq i32 [[RET]], 9 109; NEW_PM-NEXT: [[CMP_EQ_3:%.*]] = icmp eq i32 [[RET]], 8 110; NEW_PM-NEXT: [[CMP_EQ_4:%.*]] = icmp eq i32 [[RET]], 1 111; NEW_PM-NEXT: [[CMP_EQ_5:%.*]] = icmp eq i32 [[RET]], 0 112; NEW_PM-NEXT: tail call void @use3(i1 false, i1 [[CMP_EQ_2]], i1 [[CMP_EQ_3]]) 113; NEW_PM-NEXT: tail call void @use3(i1 [[CMP_EQ_4]], i1 [[CMP_EQ_5]], i1 false) 114; NEW_PM-NEXT: [[CMP_NE_2:%.*]] = icmp ne i32 [[RET]], 9 115; NEW_PM-NEXT: [[CMP_NE_3:%.*]] = icmp ne i32 [[RET]], 8 116; NEW_PM-NEXT: [[CMP_NE_4:%.*]] = icmp ne i32 [[RET]], 1 117; NEW_PM-NEXT: [[CMP_NE_5:%.*]] = icmp ne i32 [[RET]], 0 118; NEW_PM-NEXT: tail call void @use3(i1 true, i1 [[CMP_NE_2]], i1 [[CMP_NE_3]]) 119; NEW_PM-NEXT: tail call void @use3(i1 [[CMP_NE_4]], i1 [[CMP_NE_5]], i1 true) 120; NEW_PM-NEXT: [[CMP_UGT_3:%.*]] = icmp ugt i32 [[RET]], 8 121; NEW_PM-NEXT: [[CMP_UGT_4:%.*]] = icmp ugt i32 [[RET]], 1 122; NEW_PM-NEXT: [[CMP_UGT_5:%.*]] = icmp ugt i32 [[RET]], 0 123; NEW_PM-NEXT: tail call void @use3(i1 false, i1 false, i1 [[CMP_UGT_3]]) 124; NEW_PM-NEXT: tail call void @use3(i1 [[CMP_UGT_4]], i1 [[CMP_UGT_5]], i1 false) 125; NEW_PM-NEXT: [[CMP_UGE_2:%.*]] = icmp uge i32 [[RET]], 9 126; NEW_PM-NEXT: [[CMP_UGE_3:%.*]] = icmp uge i32 [[RET]], 8 127; NEW_PM-NEXT: [[CMP_UGE_4:%.*]] = icmp uge i32 [[RET]], 1 128; NEW_PM-NEXT: tail call void @use3(i1 false, i1 [[CMP_UGE_2]], i1 [[CMP_UGE_3]]) 129; NEW_PM-NEXT: tail call void @use3(i1 [[CMP_UGE_4]], i1 true, i1 false) 130; NEW_PM-NEXT: [[CMP_SGT_3:%.*]] = icmp sgt i32 [[RET]], 8 131; NEW_PM-NEXT: [[CMP_SGT_4:%.*]] = icmp sgt i32 [[RET]], 1 132; NEW_PM-NEXT: [[CMP_SGT_5:%.*]] = icmp sgt i32 [[RET]], 0 133; NEW_PM-NEXT: tail call void @use3(i1 false, i1 false, i1 [[CMP_SGT_3]]) 134; NEW_PM-NEXT: tail call void @use3(i1 [[CMP_SGT_4]], i1 [[CMP_SGT_5]], i1 true) 135; NEW_PM-NEXT: [[CMP_GTE_2:%.*]] = icmp sge i32 [[RET]], 9 136; NEW_PM-NEXT: [[CMP_GTE_3:%.*]] = icmp sge i32 [[RET]], 8 137; NEW_PM-NEXT: [[CMP_GTE_4:%.*]] = icmp sge i32 [[RET]], 1 138; NEW_PM-NEXT: tail call void @use3(i1 false, i1 [[CMP_GTE_2]], i1 [[CMP_GTE_3]]) 139; NEW_PM-NEXT: tail call void @use3(i1 [[CMP_GTE_4]], i1 true, i1 true) 140; NEW_PM-NEXT: [[CMP_SLT_2:%.*]] = icmp slt i32 [[RET]], 9 141; NEW_PM-NEXT: [[CMP_SLT_3:%.*]] = icmp slt i32 [[RET]], 8 142; NEW_PM-NEXT: [[CMP_SLT_4:%.*]] = icmp slt i32 [[RET]], 1 143; NEW_PM-NEXT: tail call void @use3(i1 true, i1 [[CMP_SLT_2]], i1 [[CMP_SLT_3]]) 144; NEW_PM-NEXT: tail call void @use3(i1 [[CMP_SLT_4]], i1 false, i1 false) 145; NEW_PM-NEXT: [[CMP_LTE_3:%.*]] = icmp sle i32 [[RET]], 8 146; NEW_PM-NEXT: [[CMP_LTE_4:%.*]] = icmp sle i32 [[RET]], 1 147; NEW_PM-NEXT: [[CMP_LTE_5:%.*]] = icmp sle i32 [[RET]], 0 148; NEW_PM-NEXT: tail call void @use3(i1 true, i1 true, i1 [[CMP_LTE_3]]) 149; NEW_PM-NEXT: tail call void @use3(i1 [[CMP_LTE_4]], i1 [[CMP_LTE_5]], i1 false) 150; NEW_PM-NEXT: ret void 151; 152; CGSCC_OLD_PM-LABEL: define {{[^@]+}}@test0-icmp-check 153; CGSCC_OLD_PM-SAME: (i32* nocapture nofree nonnull readonly align 4 dereferenceable(4) [[P:%.*]]) 154; CGSCC_OLD_PM-NEXT: [[RET:%.*]] = tail call i32 @test0(i32* nocapture nofree nonnull readonly align 4 dereferenceable(4) [[P]]) 155; CGSCC_OLD_PM-NEXT: [[CMP_EQ_1:%.*]] = icmp eq i32 [[RET]], 10 156; CGSCC_OLD_PM-NEXT: [[CMP_EQ_2:%.*]] = icmp eq i32 [[RET]], 9 157; CGSCC_OLD_PM-NEXT: [[CMP_EQ_3:%.*]] = icmp eq i32 [[RET]], 8 158; CGSCC_OLD_PM-NEXT: [[CMP_EQ_4:%.*]] = icmp eq i32 [[RET]], 1 159; CGSCC_OLD_PM-NEXT: [[CMP_EQ_5:%.*]] = icmp eq i32 [[RET]], 0 160; CGSCC_OLD_PM-NEXT: [[CMP_EQ_6:%.*]] = icmp eq i32 [[RET]], -1 161; CGSCC_OLD_PM-NEXT: tail call void @use3(i1 [[CMP_EQ_1]], i1 [[CMP_EQ_2]], i1 [[CMP_EQ_3]]) 162; CGSCC_OLD_PM-NEXT: tail call void @use3(i1 [[CMP_EQ_4]], i1 [[CMP_EQ_5]], i1 [[CMP_EQ_6]]) 163; CGSCC_OLD_PM-NEXT: [[CMP_NE_1:%.*]] = icmp ne i32 [[RET]], 10 164; CGSCC_OLD_PM-NEXT: [[CMP_NE_2:%.*]] = icmp ne i32 [[RET]], 9 165; CGSCC_OLD_PM-NEXT: [[CMP_NE_3:%.*]] = icmp ne i32 [[RET]], 8 166; CGSCC_OLD_PM-NEXT: [[CMP_NE_4:%.*]] = icmp ne i32 [[RET]], 1 167; CGSCC_OLD_PM-NEXT: [[CMP_NE_5:%.*]] = icmp ne i32 [[RET]], 0 168; CGSCC_OLD_PM-NEXT: [[CMP_NE_6:%.*]] = icmp ne i32 [[RET]], -1 169; CGSCC_OLD_PM-NEXT: tail call void @use3(i1 [[CMP_NE_1]], i1 [[CMP_NE_2]], i1 [[CMP_NE_3]]) 170; CGSCC_OLD_PM-NEXT: tail call void @use3(i1 [[CMP_NE_4]], i1 [[CMP_NE_5]], i1 [[CMP_NE_6]]) 171; CGSCC_OLD_PM-NEXT: [[CMP_UGT_1:%.*]] = icmp ugt i32 [[RET]], 10 172; CGSCC_OLD_PM-NEXT: [[CMP_UGT_2:%.*]] = icmp ugt i32 [[RET]], 9 173; CGSCC_OLD_PM-NEXT: [[CMP_UGT_3:%.*]] = icmp ugt i32 [[RET]], 8 174; CGSCC_OLD_PM-NEXT: [[CMP_UGT_4:%.*]] = icmp ugt i32 [[RET]], 1 175; CGSCC_OLD_PM-NEXT: [[CMP_UGT_5:%.*]] = icmp ugt i32 [[RET]], 0 176; CGSCC_OLD_PM-NEXT: tail call void @use3(i1 [[CMP_UGT_1]], i1 [[CMP_UGT_2]], i1 [[CMP_UGT_3]]) 177; CGSCC_OLD_PM-NEXT: tail call void @use3(i1 [[CMP_UGT_4]], i1 [[CMP_UGT_5]], i1 false) 178; CGSCC_OLD_PM-NEXT: [[CMP_UGE_1:%.*]] = icmp uge i32 [[RET]], 10 179; CGSCC_OLD_PM-NEXT: [[CMP_UGE_2:%.*]] = icmp uge i32 [[RET]], 9 180; CGSCC_OLD_PM-NEXT: [[CMP_UGE_3:%.*]] = icmp uge i32 [[RET]], 8 181; CGSCC_OLD_PM-NEXT: [[CMP_UGE_4:%.*]] = icmp uge i32 [[RET]], 1 182; CGSCC_OLD_PM-NEXT: [[CMP_UGE_6:%.*]] = icmp uge i32 [[RET]], -1 183; CGSCC_OLD_PM-NEXT: tail call void @use3(i1 [[CMP_UGE_1]], i1 [[CMP_UGE_2]], i1 [[CMP_UGE_3]]) 184; CGSCC_OLD_PM-NEXT: tail call void @use3(i1 [[CMP_UGE_4]], i1 true, i1 [[CMP_UGE_6]]) 185; CGSCC_OLD_PM-NEXT: [[CMP_SGT_1:%.*]] = icmp sgt i32 [[RET]], 10 186; CGSCC_OLD_PM-NEXT: [[CMP_SGT_2:%.*]] = icmp sgt i32 [[RET]], 9 187; CGSCC_OLD_PM-NEXT: [[CMP_SGT_3:%.*]] = icmp sgt i32 [[RET]], 8 188; CGSCC_OLD_PM-NEXT: [[CMP_SGT_4:%.*]] = icmp sgt i32 [[RET]], 1 189; CGSCC_OLD_PM-NEXT: [[CMP_SGT_5:%.*]] = icmp sgt i32 [[RET]], 0 190; CGSCC_OLD_PM-NEXT: [[CMP_SGT_6:%.*]] = icmp sgt i32 [[RET]], -1 191; CGSCC_OLD_PM-NEXT: tail call void @use3(i1 [[CMP_SGT_1]], i1 [[CMP_SGT_2]], i1 [[CMP_SGT_3]]) 192; CGSCC_OLD_PM-NEXT: tail call void @use3(i1 [[CMP_SGT_4]], i1 [[CMP_SGT_5]], i1 [[CMP_SGT_6]]) 193; CGSCC_OLD_PM-NEXT: [[CMP_GTE_1:%.*]] = icmp sge i32 [[RET]], 10 194; CGSCC_OLD_PM-NEXT: [[CMP_GTE_2:%.*]] = icmp sge i32 [[RET]], 9 195; CGSCC_OLD_PM-NEXT: [[CMP_GTE_3:%.*]] = icmp sge i32 [[RET]], 8 196; CGSCC_OLD_PM-NEXT: [[CMP_GTE_4:%.*]] = icmp sge i32 [[RET]], 1 197; CGSCC_OLD_PM-NEXT: [[CMP_GTE_5:%.*]] = icmp sge i32 [[RET]], 0 198; CGSCC_OLD_PM-NEXT: [[CMP_GTE_6:%.*]] = icmp sge i32 [[RET]], -1 199; CGSCC_OLD_PM-NEXT: tail call void @use3(i1 [[CMP_GTE_1]], i1 [[CMP_GTE_2]], i1 [[CMP_GTE_3]]) 200; CGSCC_OLD_PM-NEXT: tail call void @use3(i1 [[CMP_GTE_4]], i1 [[CMP_GTE_5]], i1 [[CMP_GTE_6]]) 201; CGSCC_OLD_PM-NEXT: [[CMP_SLT_1:%.*]] = icmp slt i32 [[RET]], 10 202; CGSCC_OLD_PM-NEXT: [[CMP_SLT_2:%.*]] = icmp slt i32 [[RET]], 9 203; CGSCC_OLD_PM-NEXT: [[CMP_SLT_3:%.*]] = icmp slt i32 [[RET]], 8 204; CGSCC_OLD_PM-NEXT: [[CMP_SLT_4:%.*]] = icmp slt i32 [[RET]], 1 205; CGSCC_OLD_PM-NEXT: [[CMP_SLT_5:%.*]] = icmp slt i32 [[RET]], 0 206; CGSCC_OLD_PM-NEXT: [[CMP_SLT_6:%.*]] = icmp slt i32 [[RET]], -1 207; CGSCC_OLD_PM-NEXT: tail call void @use3(i1 [[CMP_SLT_1]], i1 [[CMP_SLT_2]], i1 [[CMP_SLT_3]]) 208; CGSCC_OLD_PM-NEXT: tail call void @use3(i1 [[CMP_SLT_4]], i1 [[CMP_SLT_5]], i1 [[CMP_SLT_6]]) 209; CGSCC_OLD_PM-NEXT: [[CMP_LTE_1:%.*]] = icmp sle i32 [[RET]], 10 210; CGSCC_OLD_PM-NEXT: [[CMP_LTE_2:%.*]] = icmp sle i32 [[RET]], 9 211; CGSCC_OLD_PM-NEXT: [[CMP_LTE_3:%.*]] = icmp sle i32 [[RET]], 8 212; CGSCC_OLD_PM-NEXT: [[CMP_LTE_4:%.*]] = icmp sle i32 [[RET]], 1 213; CGSCC_OLD_PM-NEXT: [[CMP_LTE_5:%.*]] = icmp sle i32 [[RET]], 0 214; CGSCC_OLD_PM-NEXT: [[CMP_LTE_6:%.*]] = icmp sle i32 [[RET]], -1 215; CGSCC_OLD_PM-NEXT: tail call void @use3(i1 [[CMP_LTE_1]], i1 [[CMP_LTE_2]], i1 [[CMP_LTE_3]]) 216; CGSCC_OLD_PM-NEXT: tail call void @use3(i1 [[CMP_LTE_4]], i1 [[CMP_LTE_5]], i1 [[CMP_LTE_6]]) 217; CGSCC_OLD_PM-NEXT: ret void 218; 219; CGSCC_NEW_PM-LABEL: define {{[^@]+}}@test0-icmp-check 220; CGSCC_NEW_PM-SAME: (i32* nocapture nofree nonnull readonly align 4 dereferenceable(4) [[P:%.*]]) 221; CGSCC_NEW_PM-NEXT: [[RET:%.*]] = tail call i32 @test0(i32* nocapture nofree nonnull readonly align 4 dereferenceable(4) [[P]]) 222; CGSCC_NEW_PM-NEXT: [[CMP_EQ_1:%.*]] = icmp eq i32 [[RET]], 10 223; CGSCC_NEW_PM-NEXT: [[CMP_EQ_2:%.*]] = icmp eq i32 [[RET]], 9 224; CGSCC_NEW_PM-NEXT: [[CMP_EQ_3:%.*]] = icmp eq i32 [[RET]], 8 225; CGSCC_NEW_PM-NEXT: [[CMP_EQ_4:%.*]] = icmp eq i32 [[RET]], 1 226; CGSCC_NEW_PM-NEXT: [[CMP_EQ_5:%.*]] = icmp eq i32 [[RET]], 0 227; CGSCC_NEW_PM-NEXT: [[CMP_EQ_6:%.*]] = icmp eq i32 [[RET]], -1 228; CGSCC_NEW_PM-NEXT: tail call void @use3(i1 [[CMP_EQ_1]], i1 [[CMP_EQ_2]], i1 [[CMP_EQ_3]]) 229; CGSCC_NEW_PM-NEXT: tail call void @use3(i1 [[CMP_EQ_4]], i1 [[CMP_EQ_5]], i1 [[CMP_EQ_6]]) 230; CGSCC_NEW_PM-NEXT: [[CMP_NE_1:%.*]] = icmp ne i32 [[RET]], 10 231; CGSCC_NEW_PM-NEXT: [[CMP_NE_2:%.*]] = icmp ne i32 [[RET]], 9 232; CGSCC_NEW_PM-NEXT: [[CMP_NE_3:%.*]] = icmp ne i32 [[RET]], 8 233; CGSCC_NEW_PM-NEXT: [[CMP_NE_4:%.*]] = icmp ne i32 [[RET]], 1 234; CGSCC_NEW_PM-NEXT: [[CMP_NE_5:%.*]] = icmp ne i32 [[RET]], 0 235; CGSCC_NEW_PM-NEXT: [[CMP_NE_6:%.*]] = icmp ne i32 [[RET]], -1 236; CGSCC_NEW_PM-NEXT: tail call void @use3(i1 [[CMP_NE_1]], i1 [[CMP_NE_2]], i1 [[CMP_NE_3]]) 237; CGSCC_NEW_PM-NEXT: tail call void @use3(i1 [[CMP_NE_4]], i1 [[CMP_NE_5]], i1 [[CMP_NE_6]]) 238; CGSCC_NEW_PM-NEXT: [[CMP_UGT_1:%.*]] = icmp ugt i32 [[RET]], 10 239; CGSCC_NEW_PM-NEXT: [[CMP_UGT_2:%.*]] = icmp ugt i32 [[RET]], 9 240; CGSCC_NEW_PM-NEXT: [[CMP_UGT_3:%.*]] = icmp ugt i32 [[RET]], 8 241; CGSCC_NEW_PM-NEXT: [[CMP_UGT_4:%.*]] = icmp ugt i32 [[RET]], 1 242; CGSCC_NEW_PM-NEXT: [[CMP_UGT_5:%.*]] = icmp ugt i32 [[RET]], 0 243; CGSCC_NEW_PM-NEXT: tail call void @use3(i1 [[CMP_UGT_1]], i1 [[CMP_UGT_2]], i1 [[CMP_UGT_3]]) 244; CGSCC_NEW_PM-NEXT: tail call void @use3(i1 [[CMP_UGT_4]], i1 [[CMP_UGT_5]], i1 false) 245; CGSCC_NEW_PM-NEXT: [[CMP_UGE_1:%.*]] = icmp uge i32 [[RET]], 10 246; CGSCC_NEW_PM-NEXT: [[CMP_UGE_2:%.*]] = icmp uge i32 [[RET]], 9 247; CGSCC_NEW_PM-NEXT: [[CMP_UGE_3:%.*]] = icmp uge i32 [[RET]], 8 248; CGSCC_NEW_PM-NEXT: [[CMP_UGE_4:%.*]] = icmp uge i32 [[RET]], 1 249; CGSCC_NEW_PM-NEXT: [[CMP_UGE_6:%.*]] = icmp uge i32 [[RET]], -1 250; CGSCC_NEW_PM-NEXT: tail call void @use3(i1 [[CMP_UGE_1]], i1 [[CMP_UGE_2]], i1 [[CMP_UGE_3]]) 251; CGSCC_NEW_PM-NEXT: tail call void @use3(i1 [[CMP_UGE_4]], i1 true, i1 [[CMP_UGE_6]]) 252; CGSCC_NEW_PM-NEXT: [[CMP_SGT_1:%.*]] = icmp sgt i32 [[RET]], 10 253; CGSCC_NEW_PM-NEXT: [[CMP_SGT_2:%.*]] = icmp sgt i32 [[RET]], 9 254; CGSCC_NEW_PM-NEXT: [[CMP_SGT_3:%.*]] = icmp sgt i32 [[RET]], 8 255; CGSCC_NEW_PM-NEXT: [[CMP_SGT_4:%.*]] = icmp sgt i32 [[RET]], 1 256; CGSCC_NEW_PM-NEXT: [[CMP_SGT_5:%.*]] = icmp sgt i32 [[RET]], 0 257; CGSCC_NEW_PM-NEXT: [[CMP_SGT_6:%.*]] = icmp sgt i32 [[RET]], -1 258; CGSCC_NEW_PM-NEXT: tail call void @use3(i1 [[CMP_SGT_1]], i1 [[CMP_SGT_2]], i1 [[CMP_SGT_3]]) 259; CGSCC_NEW_PM-NEXT: tail call void @use3(i1 [[CMP_SGT_4]], i1 [[CMP_SGT_5]], i1 [[CMP_SGT_6]]) 260; CGSCC_NEW_PM-NEXT: [[CMP_GTE_1:%.*]] = icmp sge i32 [[RET]], 10 261; CGSCC_NEW_PM-NEXT: [[CMP_GTE_2:%.*]] = icmp sge i32 [[RET]], 9 262; CGSCC_NEW_PM-NEXT: [[CMP_GTE_3:%.*]] = icmp sge i32 [[RET]], 8 263; CGSCC_NEW_PM-NEXT: [[CMP_GTE_4:%.*]] = icmp sge i32 [[RET]], 1 264; CGSCC_NEW_PM-NEXT: [[CMP_GTE_5:%.*]] = icmp sge i32 [[RET]], 0 265; CGSCC_NEW_PM-NEXT: [[CMP_GTE_6:%.*]] = icmp sge i32 [[RET]], -1 266; CGSCC_NEW_PM-NEXT: tail call void @use3(i1 [[CMP_GTE_1]], i1 [[CMP_GTE_2]], i1 [[CMP_GTE_3]]) 267; CGSCC_NEW_PM-NEXT: tail call void @use3(i1 [[CMP_GTE_4]], i1 [[CMP_GTE_5]], i1 [[CMP_GTE_6]]) 268; CGSCC_NEW_PM-NEXT: [[CMP_SLT_1:%.*]] = icmp slt i32 [[RET]], 10 269; CGSCC_NEW_PM-NEXT: [[CMP_SLT_2:%.*]] = icmp slt i32 [[RET]], 9 270; CGSCC_NEW_PM-NEXT: [[CMP_SLT_3:%.*]] = icmp slt i32 [[RET]], 8 271; CGSCC_NEW_PM-NEXT: [[CMP_SLT_4:%.*]] = icmp slt i32 [[RET]], 1 272; CGSCC_NEW_PM-NEXT: [[CMP_SLT_5:%.*]] = icmp slt i32 [[RET]], 0 273; CGSCC_NEW_PM-NEXT: [[CMP_SLT_6:%.*]] = icmp slt i32 [[RET]], -1 274; CGSCC_NEW_PM-NEXT: tail call void @use3(i1 [[CMP_SLT_1]], i1 [[CMP_SLT_2]], i1 [[CMP_SLT_3]]) 275; CGSCC_NEW_PM-NEXT: tail call void @use3(i1 [[CMP_SLT_4]], i1 [[CMP_SLT_5]], i1 [[CMP_SLT_6]]) 276; CGSCC_NEW_PM-NEXT: [[CMP_LTE_1:%.*]] = icmp sle i32 [[RET]], 10 277; CGSCC_NEW_PM-NEXT: [[CMP_LTE_2:%.*]] = icmp sle i32 [[RET]], 9 278; CGSCC_NEW_PM-NEXT: [[CMP_LTE_3:%.*]] = icmp sle i32 [[RET]], 8 279; CGSCC_NEW_PM-NEXT: [[CMP_LTE_4:%.*]] = icmp sle i32 [[RET]], 1 280; CGSCC_NEW_PM-NEXT: [[CMP_LTE_5:%.*]] = icmp sle i32 [[RET]], 0 281; CGSCC_NEW_PM-NEXT: [[CMP_LTE_6:%.*]] = icmp sle i32 [[RET]], -1 282; CGSCC_NEW_PM-NEXT: tail call void @use3(i1 [[CMP_LTE_1]], i1 [[CMP_LTE_2]], i1 [[CMP_LTE_3]]) 283; CGSCC_NEW_PM-NEXT: tail call void @use3(i1 [[CMP_LTE_4]], i1 [[CMP_LTE_5]], i1 [[CMP_LTE_6]]) 284; CGSCC_NEW_PM-NEXT: ret void 285; 286 ; ret = [0, 10) 287 %ret = tail call i32 @test0(i32 *%p) 288 289 ; ret = [0, 10), eq 290 %cmp-eq-1 = icmp eq i32 %ret, 10 291 %cmp-eq-2 = icmp eq i32 %ret, 9 292 %cmp-eq-3 = icmp eq i32 %ret, 8 293 %cmp-eq-4 = icmp eq i32 %ret, 1 294 %cmp-eq-5 = icmp eq i32 %ret, 0 295 %cmp-eq-6 = icmp eq i32 %ret, -1 296 tail call void @use3(i1 %cmp-eq-1, i1 %cmp-eq-2, i1 %cmp-eq-3) 297 tail call void @use3(i1 %cmp-eq-4, i1 %cmp-eq-5, i1 %cmp-eq-6) 298 299 ; ret = [0, 10), ne 300 %cmp-ne-1 = icmp ne i32 %ret, 10 301 %cmp-ne-2 = icmp ne i32 %ret, 9 302 %cmp-ne-3 = icmp ne i32 %ret, 8 303 %cmp-ne-4 = icmp ne i32 %ret, 1 304 %cmp-ne-5 = icmp ne i32 %ret, 0 305 %cmp-ne-6 = icmp ne i32 %ret, -1 306 tail call void @use3(i1 %cmp-ne-1, i1 %cmp-ne-2, i1 %cmp-ne-3) 307 tail call void @use3(i1 %cmp-ne-4, i1 %cmp-ne-5, i1 %cmp-ne-6) 308 309 ; ret = [0, 10), ugt 310 %cmp-ugt-1 = icmp ugt i32 %ret, 10 311 %cmp-ugt-2 = icmp ugt i32 %ret, 9 312 %cmp-ugt-3 = icmp ugt i32 %ret, 8 313 %cmp-ugt-4 = icmp ugt i32 %ret, 1 314 %cmp-ugt-5 = icmp ugt i32 %ret, 0 315 %cmp-ugt-6 = icmp ugt i32 %ret, -1 316 tail call void @use3(i1 %cmp-ugt-1, i1 %cmp-ugt-2, i1 %cmp-ugt-3) 317 tail call void @use3(i1 %cmp-ugt-4, i1 %cmp-ugt-5, i1 %cmp-ugt-6) 318 319 ; ret = [0, 10), uge 320 %cmp-uge-1 = icmp uge i32 %ret, 10 321 %cmp-uge-2 = icmp uge i32 %ret, 9 322 %cmp-uge-3 = icmp uge i32 %ret, 8 323 %cmp-uge-4 = icmp uge i32 %ret, 1 324 %cmp-uge-5 = icmp uge i32 %ret, 0 325 %cmp-uge-6 = icmp uge i32 %ret, -1 326 tail call void @use3(i1 %cmp-uge-1, i1 %cmp-uge-2, i1 %cmp-uge-3) 327 tail call void @use3(i1 %cmp-uge-4, i1 %cmp-uge-5, i1 %cmp-uge-6) 328 329 ; ret = [0, 10), sgt 330 %cmp-sgt-1 = icmp sgt i32 %ret, 10 331 %cmp-sgt-2 = icmp sgt i32 %ret, 9 332 %cmp-sgt-3 = icmp sgt i32 %ret, 8 333 %cmp-sgt-4 = icmp sgt i32 %ret, 1 334 %cmp-sgt-5 = icmp sgt i32 %ret, 0 335 %cmp-sgt-6 = icmp sgt i32 %ret, -1 336 tail call void @use3(i1 %cmp-sgt-1, i1 %cmp-sgt-2, i1 %cmp-sgt-3) 337 tail call void @use3(i1 %cmp-sgt-4, i1 %cmp-sgt-5, i1 %cmp-sgt-6) 338 339 ; ret = [0, 10), sge 340 %cmp-gte-1 = icmp sge i32 %ret, 10 341 %cmp-gte-2 = icmp sge i32 %ret, 9 342 %cmp-gte-3 = icmp sge i32 %ret, 8 343 %cmp-gte-4 = icmp sge i32 %ret, 1 344 %cmp-gte-5 = icmp sge i32 %ret, 0 345 %cmp-gte-6 = icmp sge i32 %ret, -1 346 tail call void @use3(i1 %cmp-gte-1, i1 %cmp-gte-2, i1 %cmp-gte-3) 347 tail call void @use3(i1 %cmp-gte-4, i1 %cmp-gte-5, i1 %cmp-gte-6) 348 349 ; ret = [0, 10), slt 350 %cmp-slt-1 = icmp slt i32 %ret, 10 351 %cmp-slt-2 = icmp slt i32 %ret, 9 352 %cmp-slt-3 = icmp slt i32 %ret, 8 353 %cmp-slt-4 = icmp slt i32 %ret, 1 354 %cmp-slt-5 = icmp slt i32 %ret, 0 355 %cmp-slt-6 = icmp slt i32 %ret, -1 356 tail call void @use3(i1 %cmp-slt-1, i1 %cmp-slt-2, i1 %cmp-slt-3) 357 tail call void @use3(i1 %cmp-slt-4, i1 %cmp-slt-5, i1 %cmp-slt-6) 358 359 ; ret = [0, 10), sle 360 %cmp-lte-1 = icmp sle i32 %ret, 10 361 %cmp-lte-2 = icmp sle i32 %ret, 9 362 %cmp-lte-3 = icmp sle i32 %ret, 8 363 %cmp-lte-4 = icmp sle i32 %ret, 1 364 %cmp-lte-5 = icmp sle i32 %ret, 0 365 %cmp-lte-6 = icmp sle i32 %ret, -1 366 tail call void @use3(i1 %cmp-lte-1, i1 %cmp-lte-2, i1 %cmp-lte-3) 367 tail call void @use3(i1 %cmp-lte-4, i1 %cmp-lte-5, i1 %cmp-lte-6) 368 369 ret void 370} 371define i32 @test1(i32* %p) { 372; CHECK-LABEL: define {{[^@]+}}@test1 373; CHECK-SAME: (i32* nocapture nofree nonnull readonly align 4 dereferenceable(4) [[P:%.*]]) 374; CHECK-NEXT: [[LOAD_10_100:%.*]] = load i32, i32* [[P]], align 4, !range !1 375; CHECK-NEXT: [[ADD_10_THEN_20_110:%.*]] = add i32 [[LOAD_10_100]], 10 376; CHECK-NEXT: [[MUL_10_THEN_200_1091:%.*]] = mul i32 [[ADD_10_THEN_20_110]], 10 377; CHECK-NEXT: ret i32 [[MUL_10_THEN_200_1091]] 378; 379 %load-10-100 = load i32, i32* %p, !range !1 380 %add-10-then-20-110 = add i32 %load-10-100, 10 381 %mul-10-then-200-1091 = mul i32 %add-10-then-20-110, 10 382 ret i32 %mul-10-then-200-1091 383} 384 385define i1 @test1-check(i32* %p) { 386; OLD_PM-LABEL: define {{[^@]+}}@test1-check 387; OLD_PM-SAME: (i32* nocapture nofree readonly align 4 [[P:%.*]]) 388; OLD_PM-NEXT: [[RES:%.*]] = tail call i32 @test1(i32* nocapture nofree readonly align 4 [[P]]) #{{[0-9]+}}, !range !2 389; OLD_PM-NEXT: [[CMP:%.*]] = icmp eq i32 [[RES]], 500 390; OLD_PM-NEXT: ret i1 [[CMP]] 391; 392; NEW_PM-LABEL: define {{[^@]+}}@test1-check 393; NEW_PM-SAME: (i32* nocapture nofree readonly align 4 [[P:%.*]]) 394; NEW_PM-NEXT: [[RES:%.*]] = tail call i32 @test1(i32* nocapture nofree readonly align 4 [[P]]) #{{[0-9]+}}, !range !2 395; NEW_PM-NEXT: [[CMP:%.*]] = icmp eq i32 [[RES]], 500 396; NEW_PM-NEXT: ret i1 [[CMP]] 397; 398; CGSCC_OLD_PM-LABEL: define {{[^@]+}}@test1-check 399; CGSCC_OLD_PM-SAME: (i32* nocapture nofree nonnull readonly align 4 dereferenceable(4) [[P:%.*]]) 400; CGSCC_OLD_PM-NEXT: [[RES:%.*]] = tail call i32 @test1(i32* nocapture nofree nonnull readonly align 4 dereferenceable(4) [[P]]) 401; CGSCC_OLD_PM-NEXT: [[CMP:%.*]] = icmp eq i32 [[RES]], 500 402; CGSCC_OLD_PM-NEXT: ret i1 [[CMP]] 403; 404; CGSCC_NEW_PM-LABEL: define {{[^@]+}}@test1-check 405; CGSCC_NEW_PM-SAME: (i32* nocapture nofree nonnull readonly align 4 dereferenceable(4) [[P:%.*]]) 406; CGSCC_NEW_PM-NEXT: [[RES:%.*]] = tail call i32 @test1(i32* nocapture nofree nonnull readonly align 4 dereferenceable(4) [[P]]) 407; CGSCC_NEW_PM-NEXT: [[CMP:%.*]] = icmp eq i32 [[RES]], 500 408; CGSCC_NEW_PM-NEXT: ret i1 [[CMP]] 409; 410 %res = tail call i32 @test1(i32* %p) 411 %cmp = icmp eq i32 %res, 500 412 ret i1 %cmp 413} 414 415; TEST2 416; int test2(int *p) { return *p == 0 ? 4 : 3; } 417; int test2_check(int *p) { 418; int call = test2(p); 419; if (call == 5) { 420; // dead block 421; return 2; 422; } else { 423; return 3; 424; } 425; } 426 427define i32 @test2(i32* %p) { 428; CHECK-LABEL: define {{[^@]+}}@test2 429; CHECK-SAME: (i32* nocapture nofree nonnull readonly align 4 dereferenceable(4) [[P:%.*]]) 430; CHECK-NEXT: entry: 431; CHECK-NEXT: [[TMP0:%.*]] = load i32, i32* [[P]], align 4 432; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i32 [[TMP0]], 0 433; CHECK-NEXT: [[COND:%.*]] = select i1 [[TOBOOL]], i32 4, i32 3 434; CHECK-NEXT: ret i32 [[COND]] 435; 436entry: 437 %0 = load i32, i32* %p, align 4 438 %tobool = icmp eq i32 %0, 0 439 %cond = select i1 %tobool, i32 4, i32 3 440 ret i32 %cond 441} 442 443define i32 @test2_check(i32* %p) { 444; OLD_PM-LABEL: define {{[^@]+}}@test2_check 445; OLD_PM-SAME: (i32* nocapture nofree readnone align 4 [[P:%.*]]) 446; OLD_PM-NEXT: entry: 447; OLD_PM-NEXT: br label [[IF_THEN:%.*]] 448; OLD_PM: if.then: 449; OLD_PM-NEXT: br label [[RETURN:%.*]] 450; OLD_PM: if.end: 451; OLD_PM-NEXT: unreachable 452; OLD_PM: return: 453; OLD_PM-NEXT: ret i32 2 454; 455; NEW_PM-LABEL: define {{[^@]+}}@test2_check 456; NEW_PM-SAME: (i32* nocapture nofree readnone align 4 [[P:%.*]]) 457; NEW_PM-NEXT: entry: 458; NEW_PM-NEXT: br label [[IF_THEN:%.*]] 459; NEW_PM: if.then: 460; NEW_PM-NEXT: br label [[RETURN:%.*]] 461; NEW_PM: if.end: 462; NEW_PM-NEXT: unreachable 463; NEW_PM: return: 464; NEW_PM-NEXT: ret i32 2 465; 466; CGSCC_OLD_PM-LABEL: define {{[^@]+}}@test2_check 467; CGSCC_OLD_PM-SAME: (i32* nocapture nofree nonnull readonly align 4 dereferenceable(4) [[P:%.*]]) 468; CGSCC_OLD_PM-NEXT: entry: 469; CGSCC_OLD_PM-NEXT: [[CALL:%.*]] = tail call i32 @test2(i32* nocapture nofree nonnull readonly align 4 dereferenceable(4) [[P]]) 470; CGSCC_OLD_PM-NEXT: [[CMP:%.*]] = icmp slt i32 [[CALL]], 5 471; CGSCC_OLD_PM-NEXT: br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_END:%.*]] 472; CGSCC_OLD_PM: if.then: 473; CGSCC_OLD_PM-NEXT: br label [[RETURN:%.*]] 474; CGSCC_OLD_PM: if.end: 475; CGSCC_OLD_PM-NEXT: br label [[RETURN]] 476; CGSCC_OLD_PM: return: 477; CGSCC_OLD_PM-NEXT: [[RETVAL_0:%.*]] = phi i32 [ 2, [[IF_THEN]] ], [ 3, [[IF_END]] ] 478; CGSCC_OLD_PM-NEXT: ret i32 [[RETVAL_0]] 479; 480; CGSCC_NEW_PM-LABEL: define {{[^@]+}}@test2_check 481; CGSCC_NEW_PM-SAME: (i32* nocapture nofree nonnull readonly align 4 dereferenceable(4) [[P:%.*]]) 482; CGSCC_NEW_PM-NEXT: entry: 483; CGSCC_NEW_PM-NEXT: [[CALL:%.*]] = tail call i32 @test2(i32* nocapture nofree nonnull readonly align 4 dereferenceable(4) [[P]]) 484; CGSCC_NEW_PM-NEXT: [[CMP:%.*]] = icmp slt i32 [[CALL]], 5 485; CGSCC_NEW_PM-NEXT: br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_END:%.*]] 486; CGSCC_NEW_PM: if.then: 487; CGSCC_NEW_PM-NEXT: br label [[RETURN:%.*]] 488; CGSCC_NEW_PM: if.end: 489; CGSCC_NEW_PM-NEXT: br label [[RETURN]] 490; CGSCC_NEW_PM: return: 491; CGSCC_NEW_PM-NEXT: [[RETVAL_0:%.*]] = phi i32 [ 2, [[IF_THEN]] ], [ 3, [[IF_END]] ] 492; CGSCC_NEW_PM-NEXT: ret i32 [[RETVAL_0]] 493; 494entry: 495 %call = tail call i32 @test2(i32* %p) 496 %cmp = icmp slt i32 %call, 5 497 br i1 %cmp, label %if.then, label %if.end 498 499if.then: ; preds = %entry 500 br label %return 501 502if.end: ; preds = %entry 503 br label %return 504 505return: ; preds = %if.end, %if.then 506 %retval.0 = phi i32 [ 2, %if.then ], [ 3, %if.end ] 507 ret i32 %retval.0 508} 509 510; TEST 3 SECV test 511 512; void unkown(); 513; int r1(unsigned int u){ 514; int sum = 0; 515; for(int i = 0; i<100;i++){ 516; sum += i; 517; } 518; // sum = 50 * 49 / 2 519; if(sum > 10000){ 520; // dead block 521; return 20; 522; }else { 523; return 10; 524; } 525; } 526; void f1(int u){ 527; if(r1(u) > 15){ 528; // deadblock 529; unkown(); 530; }else { 531; return; 532; } 533; } 534 535declare dso_local void @unkown() 536 537define internal i32 @r1(i32) local_unnamed_addr { 538; OLD_PM-LABEL: define {{[^@]+}}@r1() local_unnamed_addr 539; OLD_PM-NEXT: br label [[TMP4:%.*]] 540; OLD_PM: 1: 541; OLD_PM-NEXT: [[TMP2:%.*]] = icmp sgt i32 [[TMP7:%.*]], 10000 542; OLD_PM-NEXT: br i1 [[TMP2]], label [[TMP3:%.*]], label [[F:%.*]] 543; OLD_PM: 3: 544; OLD_PM-NEXT: ret i32 20 545; OLD_PM: f: 546; OLD_PM-NEXT: ret i32 10 547; OLD_PM: 4: 548; OLD_PM-NEXT: [[TMP5:%.*]] = phi i32 [ 0, [[TMP0:%.*]] ], [ [[TMP8:%.*]], [[TMP4]] ] 549; OLD_PM-NEXT: [[TMP6:%.*]] = phi i32 [ 0, [[TMP0]] ], [ [[TMP7]], [[TMP4]] ] 550; OLD_PM-NEXT: [[TMP7]] = add nuw nsw i32 [[TMP5]], [[TMP6]] 551; OLD_PM-NEXT: [[TMP8]] = add nuw nsw i32 [[TMP5]], 1 552; OLD_PM-NEXT: [[TMP9:%.*]] = icmp eq i32 [[TMP8]], 100 553; OLD_PM-NEXT: br i1 [[TMP9]], label [[TMP1:%.*]], label [[TMP4]] 554; 555; CGSCC_OLD_PM-LABEL: define {{[^@]+}}@r1() local_unnamed_addr 556; CGSCC_OLD_PM-NEXT: br label [[TMP4:%.*]] 557; CGSCC_OLD_PM: 1: 558; CGSCC_OLD_PM-NEXT: [[TMP2:%.*]] = icmp sgt i32 [[TMP7:%.*]], 10000 559; CGSCC_OLD_PM-NEXT: br i1 [[TMP2]], label [[TMP3:%.*]], label [[F:%.*]] 560; CGSCC_OLD_PM: 3: 561; CGSCC_OLD_PM-NEXT: ret i32 20 562; CGSCC_OLD_PM: f: 563; CGSCC_OLD_PM-NEXT: ret i32 10 564; CGSCC_OLD_PM: 4: 565; CGSCC_OLD_PM-NEXT: [[TMP5:%.*]] = phi i32 [ 0, [[TMP0:%.*]] ], [ [[TMP8:%.*]], [[TMP4]] ] 566; CGSCC_OLD_PM-NEXT: [[TMP6:%.*]] = phi i32 [ 0, [[TMP0]] ], [ [[TMP7]], [[TMP4]] ] 567; CGSCC_OLD_PM-NEXT: [[TMP7]] = add nuw nsw i32 [[TMP5]], [[TMP6]] 568; CGSCC_OLD_PM-NEXT: [[TMP8]] = add nuw nsw i32 [[TMP5]], 1 569; CGSCC_OLD_PM-NEXT: [[TMP9:%.*]] = icmp eq i32 [[TMP8]], 100 570; CGSCC_OLD_PM-NEXT: br i1 [[TMP9]], label [[TMP1:%.*]], label [[TMP4]] 571; 572; CGSCC_NEW_PM-LABEL: define {{[^@]+}}@r1() local_unnamed_addr 573; CGSCC_NEW_PM-NEXT: br label [[TMP3:%.*]] 574; CGSCC_NEW_PM: 1: 575; CGSCC_NEW_PM-NEXT: br label [[F:%.*]] 576; CGSCC_NEW_PM: 2: 577; CGSCC_NEW_PM-NEXT: unreachable 578; CGSCC_NEW_PM: f: 579; CGSCC_NEW_PM-NEXT: ret i32 10 580; CGSCC_NEW_PM: 3: 581; CGSCC_NEW_PM-NEXT: [[TMP4:%.*]] = phi i32 [ 0, [[TMP0:%.*]] ], [ [[TMP7:%.*]], [[TMP3]] ] 582; CGSCC_NEW_PM-NEXT: [[TMP5:%.*]] = phi i32 [ 0, [[TMP0]] ], [ [[TMP6:%.*]], [[TMP3]] ] 583; CGSCC_NEW_PM-NEXT: [[TMP6]] = add nuw nsw i32 [[TMP4]], [[TMP5]] 584; CGSCC_NEW_PM-NEXT: [[TMP7]] = add nuw nsw i32 [[TMP4]], 1 585; CGSCC_NEW_PM-NEXT: [[TMP8:%.*]] = icmp eq i32 [[TMP7]], 100 586; CGSCC_NEW_PM-NEXT: br i1 [[TMP8]], label [[TMP1:%.*]], label [[TMP3]] 587; 588 br label %5 589 5902: ; preds = %5 591 %3 = icmp sgt i32 %8, 10000 592 br i1 %3, label %4, label %f 5934: 594 ret i32 20 595f: 596 ret i32 10 5975: ; preds = %5, %1 598 %6 = phi i32 [ 0, %1 ], [ %9, %5 ] 599 %7 = phi i32 [ 0, %1 ], [ %8, %5 ] 600 %8 = add nuw nsw i32 %6, %7 601 %9 = add nuw nsw i32 %6, 1 602 %10 = icmp eq i32 %9, 100 603 br i1 %10, label %2, label %5 604} 605 606define void @f1(i32){ 607; OLD_PM-LABEL: define {{[^@]+}}@f1 608; OLD_PM-SAME: (i32 [[TMP0:%.*]]) 609; OLD_PM-NEXT: [[TMP2:%.*]] = tail call i32 @r1() 610; OLD_PM-NEXT: [[TMP3:%.*]] = icmp sgt i32 [[TMP2]], 15 611; OLD_PM-NEXT: br i1 [[TMP3]], label [[TMP4:%.*]], label [[TMP5:%.*]] 612; OLD_PM: 4: 613; OLD_PM-NEXT: tail call void @unkown() 614; OLD_PM-NEXT: br label [[TMP5]] 615; OLD_PM: 5: 616; OLD_PM-NEXT: ret void 617; 618; NEW_PM-LABEL: define {{[^@]+}}@f1 619; NEW_PM-SAME: (i32 [[TMP0:%.*]]) 620; NEW_PM-NEXT: br label [[TMP3:%.*]] 621; NEW_PM: 2: 622; NEW_PM-NEXT: unreachable 623; NEW_PM: 3: 624; NEW_PM-NEXT: ret void 625; 626; CGSCC_OLD_PM-LABEL: define {{[^@]+}}@f1 627; CGSCC_OLD_PM-SAME: (i32 [[TMP0:%.*]]) 628; CGSCC_OLD_PM-NEXT: [[TMP2:%.*]] = tail call i32 @r1() 629; CGSCC_OLD_PM-NEXT: [[TMP3:%.*]] = icmp sgt i32 [[TMP2]], 15 630; CGSCC_OLD_PM-NEXT: br i1 [[TMP3]], label [[TMP4:%.*]], label [[TMP5:%.*]] 631; CGSCC_OLD_PM: 4: 632; CGSCC_OLD_PM-NEXT: tail call void @unkown() 633; CGSCC_OLD_PM-NEXT: br label [[TMP5]] 634; CGSCC_OLD_PM: 5: 635; CGSCC_OLD_PM-NEXT: ret void 636; 637; CGSCC_NEW_PM-LABEL: define {{[^@]+}}@f1 638; CGSCC_NEW_PM-SAME: (i32 [[TMP0:%.*]]) 639; CGSCC_NEW_PM-NEXT: br label [[TMP3:%.*]] 640; CGSCC_NEW_PM: 2: 641; CGSCC_NEW_PM-NEXT: unreachable 642; CGSCC_NEW_PM: 3: 643; CGSCC_NEW_PM-NEXT: ret void 644; 645 %2 = tail call i32 @r1(i32 %0) 646 %3 = icmp sgt i32 %2, 15 647 br i1 %3, label %4, label %5 648 6494: ; preds = %1 650 tail call void @unkown() 651 br label %5 652 6535: ; preds = %1, %4 654 ret void 655} 656 657; TEST4 LVI test 658 659; f1 660; int test4-f1(int u){ 661; if(u>=0) { 662; return u; 663; }else{ 664; return 0; 665; } 666; } 667define dso_local i32 @test4-f1(i32 %u) { 668; CHECK-LABEL: define {{[^@]+}}@test4-f1 669; CHECK-SAME: (i32 [[U:%.*]]) 670; CHECK-NEXT: entry: 671; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[U]], -1 672; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN:%.*]], label [[RETURN:%.*]] 673; CHECK: if.then: 674; CHECK-NEXT: br label [[RETURN]] 675; CHECK: return: 676; CHECK-NEXT: [[RETVAL_0:%.*]] = phi i32 [ [[U]], [[IF_THEN]] ], [ 0, [[ENTRY:%.*]] ] 677; CHECK-NEXT: ret i32 [[RETVAL_0]] 678; 679; FIXME: RETVAL_0 >= 0 680entry: 681 %cmp = icmp sgt i32 %u, -1 682 br i1 %cmp, label %if.then, label %return 683 684if.then: ; preds = %entry 685 br label %return 686 687return: ; preds = %entry, %if.then 688 %retval.0 = phi i32 [ %u, %if.then ], [ 0, %entry ] 689 ret i32 %retval.0 690} 691 692 693define dso_local i32 @test4-g1(i32 %u) { 694; CHECK-LABEL: define {{[^@]+}}@test4-g1 695; CHECK-SAME: (i32 [[U:%.*]]) 696; CHECK-NEXT: entry: 697; CHECK-NEXT: [[CALL:%.*]] = tail call i32 @test4-f1(i32 [[U]]) 698; CHECK-NEXT: ret i32 [[CALL]] 699; 700; FIXME: %call should have range [0, inf] 701 702entry: 703 %call = tail call i32 @test4-f1(i32 %u) 704 ret i32 %call 705} 706 707; f2 708; int test4-f1(int u){ 709; if(u>-1) { 710; return u+1; 711; }else{ 712; return 1; 713; } 714; } 715define dso_local i32 @test4-f2(i32 %u) { 716; CHECK-LABEL: define {{[^@]+}}@test4-f2 717; CHECK-SAME: (i32 [[U:%.*]]) 718; CHECK-NEXT: entry: 719; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[U]], -1 720; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]] 721; CHECK: if.then: 722; CHECK-NEXT: [[ADD:%.*]] = add nuw nsw i32 [[U]], 1 723; CHECK-NEXT: br label [[RETURN:%.*]] 724; CHECK: if.else: 725; CHECK-NEXT: br label [[RETURN]] 726; CHECK: return: 727; CHECK-NEXT: [[RETVAL_0:%.*]] = phi i32 [ [[ADD]], [[IF_THEN]] ], [ 1, [[IF_ELSE]] ] 728; CHECK-NEXT: ret i32 [[RETVAL_0]] 729; 730entry: 731 %cmp = icmp sgt i32 %u, -1 732 br i1 %cmp, label %if.then, label %if.else 733 734if.then: ; preds = %entry 735 %add = add nuw nsw i32 %u, 1 736 br label %return 737 738if.else: ; preds = %entry 739 br label %return 740 741return: ; preds = %if.else, %if.then 742 %retval.0 = phi i32 [ %add, %if.then ], [ 1, %if.else ] 743 ret i32 %retval.0 744} 745 746 747define dso_local i32 @test4-g2(i32 %u) { 748; OLD_PM-LABEL: define {{[^@]+}}@test4-g2 749; OLD_PM-SAME: (i32 [[U:%.*]]) 750; OLD_PM-NEXT: entry: 751; OLD_PM-NEXT: [[CALL:%.*]] = tail call i32 @test4-f2(i32 [[U]]) 752; OLD_PM-NEXT: ret i32 [[CALL]] 753; 754; NEW_PM-LABEL: define {{[^@]+}}@test4-g2 755; NEW_PM-SAME: (i32 [[U:%.*]]) 756; NEW_PM-NEXT: entry: 757; NEW_PM-NEXT: [[CALL:%.*]] = tail call i32 @test4-f2(i32 [[U]]) #2, !range !3 758; NEW_PM-NEXT: ret i32 [[CALL]] 759; 760; CGSCC_OLD_PM-LABEL: define {{[^@]+}}@test4-g2 761; CGSCC_OLD_PM-SAME: (i32 [[U:%.*]]) 762; CGSCC_OLD_PM-NEXT: entry: 763; CGSCC_OLD_PM-NEXT: [[CALL:%.*]] = tail call i32 @test4-f2(i32 [[U]]) 764; CGSCC_OLD_PM-NEXT: ret i32 [[CALL]] 765; 766; CGSCC_NEW_PM-LABEL: define {{[^@]+}}@test4-g2 767; CGSCC_NEW_PM-SAME: (i32 [[U:%.*]]) 768; CGSCC_NEW_PM-NEXT: entry: 769; CGSCC_NEW_PM-NEXT: [[CALL:%.*]] = tail call i32 @test4-f2(i32 [[U]]) 770; CGSCC_NEW_PM-NEXT: ret i32 [[CALL]] 771; 772; CGSCC-LABEL: define {{[^@]+}}@test4-g2 773; CGSCC-SAME: (i32 [[U:%.*]]) 774; CGSCC-NEXT: entry: 775; CGSCC-NEXT: [[CALL:%.*]] = tail call i32 @test4-f2(i32 [[U]]) 776; CGSCC-NEXT: ret i32 [[CALL]] 777entry: 778 %call = tail call i32 @test4-f2(i32 %u) 779 ret i32 %call 780} 781 782define dso_local i32 @test-5() { 783; OLD_PM-LABEL: define {{[^@]+}}@test-5() 784; OLD_PM-NEXT: entry: 785; OLD_PM-NEXT: [[CALL:%.*]] = call i32 @rec(i32 0), !range !3 786; OLD_PM-NEXT: ret i32 [[CALL]] 787; 788; NEW_PM-LABEL: define {{[^@]+}}@test-5() 789; NEW_PM-NEXT: entry: 790; NEW_PM-NEXT: [[CALL:%.*]] = call i32 @rec(i32 0), !range !4 791; NEW_PM-NEXT: ret i32 [[CALL]] 792; 793; CGSCC_OLD_PM-LABEL: define {{[^@]+}}@test-5() 794; CGSCC_OLD_PM-NEXT: entry: 795; CGSCC_OLD_PM-NEXT: [[CALL:%.*]] = call i32 @rec(i32 0) 796; CGSCC_OLD_PM-NEXT: ret i32 [[CALL]] 797; 798; CGSCC_NEW_PM-LABEL: define {{[^@]+}}@test-5() 799; CGSCC_NEW_PM-NEXT: entry: 800; CGSCC_NEW_PM-NEXT: [[CALL:%.*]] = call i32 @rec(i32 0) 801; CGSCC_NEW_PM-NEXT: ret i32 [[CALL]] 802; 803; CGSCC-LABEL: define {{[^@]+}}@test-5() 804; CGSCC-NEXT: entry: 805; CGSCC-NEXT: [[CALL:%.*]] = call i32 @rec(i32 0) 806; CGSCC-NEXT: ret i32 [[CALL]] 807entry: 808 %call = call i32 @rec(i32 0) 809 ret i32 %call 810} 811define internal i32 @rec(i32 %depth) { 812; CHECK-LABEL: define {{[^@]+}}@rec 813; CHECK-SAME: (i32 [[DEPTH:%.*]]) 814; CHECK-NEXT: entry: 815; CHECK-NEXT: [[CALL:%.*]] = call i32 @foo(i32 [[DEPTH]]) 816; CHECK-NEXT: [[TOBOOL:%.*]] = icmp ne i32 [[CALL]], 0 817; CHECK-NEXT: br i1 [[TOBOOL]], label [[IF_THEN:%.*]], label [[IF_END:%.*]] 818; CHECK: if.then: 819; CHECK-NEXT: br label [[RETURN:%.*]] 820; CHECK: if.end: 821; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[DEPTH]], 10 822; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN1:%.*]], label [[IF_END3:%.*]] 823; CHECK: if.then1: 824; CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[DEPTH]], 1 825; CHECK-NEXT: [[CALL2:%.*]] = call i32 @rec(i32 [[ADD]]) 826; CHECK-NEXT: br label [[IF_END3]] 827; CHECK: if.end3: 828; CHECK-NEXT: br label [[RETURN]] 829; CHECK: return: 830; CHECK-NEXT: [[RETVAL_0:%.*]] = phi i32 [ 0, [[IF_THEN]] ], [ 1, [[IF_END3]] ] 831; CHECK-NEXT: ret i32 [[RETVAL_0]] 832; 833entry: 834 %call = call i32 @foo(i32 %depth) 835 %tobool = icmp ne i32 %call, 0 836 br i1 %tobool, label %if.then, label %if.end 837 838if.then: ; preds = %entry 839 br label %return 840 841if.end: ; preds = %entry 842 %cmp = icmp slt i32 %depth, 10 843 br i1 %cmp, label %if.then1, label %if.end3 844 845if.then1: ; preds = %if.end 846 %add = add nsw i32 %depth, 1 847 %call2 = call i32 @rec(i32 %add) 848 br label %if.end3 849 850if.end3: ; preds = %if.then1, %if.end 851 br label %return 852 853return: ; preds = %if.end3, %if.then 854 %retval.0 = phi i32 [ 0, %if.then ], [ 1, %if.end3 ] 855 ret i32 %retval.0 856} 857declare dso_local i32 @foo(i32) 858 859 860; Examples taken from https://llvm.discourse.group/t/impossible-condition-optimization/461/1 861; 862; The important part is that we return a constant (false) 863; 864; { 865 866; FIXME: All but the return is not needed anymore 867define dso_local zeroext i1 @phi(i32 %arg) { 868; CHECK-LABEL: define {{[^@]+}}@phi 869; CHECK-SAME: (i32 [[ARG:%.*]]) 870; CHECK-NEXT: bb: 871; CHECK-NEXT: [[TMP:%.*]] = icmp sgt i32 [[ARG]], 5 872; CHECK-NEXT: br i1 [[TMP]], label [[BB1:%.*]], label [[BB2:%.*]] 873; CHECK: bb1: 874; CHECK-NEXT: br label [[BB3:%.*]] 875; CHECK: bb2: 876; CHECK-NEXT: br label [[BB3]] 877; CHECK: bb3: 878; CHECK-NEXT: [[TMP4:%.*]] = icmp sgt i32 [[ARG]], 10 879; CHECK-NEXT: br i1 [[TMP4]], label [[BB5:%.*]], label [[BB7:%.*]] 880; CHECK: bb5: 881; CHECK-NEXT: br label [[BB9:%.*]] 882; CHECK: bb7: 883; CHECK-NEXT: br label [[BB9]] 884; CHECK: bb9: 885; CHECK-NEXT: br label [[BB12:%.*]] 886; CHECK: bb11: 887; CHECK-NEXT: unreachable 888; CHECK: bb12: 889; CHECK-NEXT: br label [[BB13:%.*]] 890; CHECK: bb13: 891; CHECK-NEXT: ret i1 false 892; 893bb: 894 %tmp = icmp sgt i32 %arg, 5 895 br i1 %tmp, label %bb1, label %bb2 896 897bb1: ; preds = %bb 898 br label %bb3 899 900bb2: ; preds = %bb 901 br label %bb3 902 903bb3: ; preds = %bb2, %bb1 904 %.02 = phi i32 [ 1, %bb1 ], [ 2, %bb2 ] 905 %tmp4 = icmp sgt i32 %arg, 10 906 br i1 %tmp4, label %bb5, label %bb7 907 908bb5: ; preds = %bb3 909 %tmp6 = add nsw i32 %.02, 1 910 br label %bb9 911 912bb7: ; preds = %bb3 913 %tmp8 = add nsw i32 %.02, 2 914 br label %bb9 915 916bb9: ; preds = %bb7, %bb5 917 %.01 = phi i32 [ %tmp6, %bb5 ], [ %tmp8, %bb7 ] 918 %tmp10 = icmp eq i32 %.01, 5 919 br i1 %tmp10, label %bb11, label %bb12 920 921bb11: ; preds = %bb9 922 br label %bb13 923 924bb12: ; preds = %bb9 925 br label %bb13 926 927bb13: ; preds = %bb12, %bb11 928 %.0 = phi i1 [ true, %bb11 ], [ false, %bb12 ] 929 ret i1 %.0 930} 931 932define dso_local i1 @select(i32 %a) local_unnamed_addr #0 { 933; CHECK-LABEL: define {{[^@]+}}@select 934; CHECK-SAME: (i32 [[A:%.*]]) local_unnamed_addr 935; CHECK-NEXT: entry: 936; CHECK-NEXT: ret i1 false 937; 938entry: 939 %cmp = icmp sgt i32 %a, 5 940 %. = select i1 %cmp, i32 1, i32 2 941 %cmp1 = icmp sgt i32 %a, 10 942 %y.0.v = select i1 %cmp1, i32 1, i32 2 943 %y.0 = add nuw nsw i32 %., %y.0.v 944 %cmp6 = icmp eq i32 %y.0, 5 945 ret i1 %cmp6 946} 947 948define dso_local i32 @select_zext(i32 %a) local_unnamed_addr #0 { 949; CHECK-LABEL: define {{[^@]+}}@select_zext 950; CHECK-SAME: (i32 [[A:%.*]]) local_unnamed_addr 951; CHECK-NEXT: entry: 952; CHECK-NEXT: ret i32 0 953; 954entry: 955 %cmp = icmp sgt i32 %a, 5 956 %. = select i1 %cmp, i32 1, i32 2 957 %cmp1 = icmp sgt i32 %a, 10 958 %y.0.v = select i1 %cmp1, i32 1, i32 2 959 %y.0 = add nuw nsw i32 %., %y.0.v 960 %cmp6 = icmp eq i32 %y.0, 5 961 %.13 = zext i1 %cmp6 to i32 962 ret i32 %.13 963} 964 965; FIXME: We do not look through the ptr casts here. 966define dso_local i64 @select_int2ptr_bitcast_ptr2int(i32 %a) local_unnamed_addr #0 { 967; CHECK-LABEL: define {{[^@]+}}@select_int2ptr_bitcast_ptr2int 968; CHECK-SAME: (i32 [[A:%.*]]) local_unnamed_addr 969; CHECK-NEXT: entry: 970; CHECK-NEXT: [[I2P:%.*]] = inttoptr i1 false to i1* 971; CHECK-NEXT: [[BC:%.*]] = bitcast i1* [[I2P]] to i32* 972; CHECK-NEXT: [[P2I:%.*]] = ptrtoint i32* [[BC]] to i64 973; CHECK-NEXT: ret i64 [[P2I]] 974; 975entry: 976 %cmp = icmp sgt i32 %a, 5 977 %. = select i1 %cmp, i32 1, i32 2 978 %cmp1 = icmp sgt i32 %a, 10 979 %y.0.v = select i1 %cmp1, i32 1, i32 2 980 %y.0 = add nuw nsw i32 %., %y.0.v 981 %cmp6 = icmp eq i32 %y.0, 5 982 %i2p = inttoptr i1 %cmp6 to i1* 983 %bc = bitcast i1* %i2p to i32* 984 %p2i = ptrtoint i32* %bc to i64 985 ret i64 %p2i 986} 987 988; } 989 990define i1 @f_fcmp(float %a, float %b) { 991; CHECK-LABEL: define {{[^@]+}}@f_fcmp 992; CHECK-SAME: (float [[A:%.*]], float [[B:%.*]]) 993; CHECK-NEXT: [[R:%.*]] = fcmp uge float [[A]], [[B]] 994; CHECK-NEXT: [[S:%.*]] = select i1 [[R]], i1 [[R]], i1 false 995; CHECK-NEXT: ret i1 [[S]] 996; 997 %r = fcmp uge float %a, %b 998 %s = select i1 %r, i1 %r, i1 0 999 ret i1 %s 1000} 1001define i1 @d_fcmp(double %a, double %b) { 1002; CHECK-LABEL: define {{[^@]+}}@d_fcmp 1003; CHECK-SAME: (double [[A:%.*]], double [[B:%.*]]) 1004; CHECK-NEXT: [[R:%.*]] = fcmp oeq double [[A]], [[B]] 1005; CHECK-NEXT: [[S:%.*]] = select i1 [[R]], i1 [[R]], i1 false 1006; CHECK-NEXT: ret i1 [[S]] 1007; 1008 %r = fcmp oeq double %a, %b 1009 %s = select i1 %r, i1 %r, i1 0 1010 ret i1 %s 1011} 1012define i1 @dp_icmp(double* %a, double* %b) { 1013; CHECK-LABEL: define {{[^@]+}}@dp_icmp 1014; CHECK-SAME: (double* nofree readnone [[A:%.*]], double* nofree readnone [[B:%.*]]) 1015; CHECK-NEXT: [[R:%.*]] = icmp sge double* [[A]], [[B]] 1016; CHECK-NEXT: [[S:%.*]] = select i1 [[R]], i1 [[R]], i1 false 1017; CHECK-NEXT: ret i1 [[S]] 1018; 1019 %r = icmp sge double* %a, %b 1020 %s = select i1 %r, i1 %r, i1 0 1021 ret i1 %s 1022} 1023define i1 @ip_icmp(i8* %a, i8* %b) { 1024; CHECK-LABEL: define {{[^@]+}}@ip_icmp 1025; CHECK-SAME: (i8* nofree readnone [[A:%.*]], i8* nofree readnone [[B:%.*]]) 1026; CHECK-NEXT: [[R:%.*]] = icmp ult i8* [[A]], [[B]] 1027; CHECK-NEXT: [[S:%.*]] = select i1 [[R]], i1 [[R]], i1 false 1028; CHECK-NEXT: ret i1 [[S]] 1029; 1030 %r = icmp ult i8* %a, %b 1031 %s = select i1 %r, i1 %r, i1 0 1032 ret i1 %s 1033} 1034define i1 @fcmp_caller(float %fa, float %fb, double %da, double %db, double* %dpa, double* %dpb, i8* %ipa, i8* %ipb) { 1035; CHECK-LABEL: define {{[^@]+}}@fcmp_caller 1036; CHECK-SAME: (float [[FA:%.*]], float [[FB:%.*]], double [[DA:%.*]], double [[DB:%.*]], double* nofree readnone [[DPA:%.*]], double* nofree readnone [[DPB:%.*]], i8* nofree readnone [[IPA:%.*]], i8* nofree readnone [[IPB:%.*]]) 1037; CHECK-NEXT: [[R1:%.*]] = call i1 @f_fcmp(float [[FA]], float [[FB]]) 1038; CHECK-NEXT: [[R2:%.*]] = call i1 @d_fcmp(double [[DA]], double [[DB]]) 1039; CHECK-NEXT: [[R3:%.*]] = call i1 @dp_icmp(double* noalias nofree readnone [[DPA]], double* noalias nofree readnone [[DPB]]) 1040; CHECK-NEXT: [[R4:%.*]] = call i1 @ip_icmp(i8* noalias nofree readnone [[IPA]], i8* noalias nofree readnone [[IPB]]) 1041; CHECK-NEXT: [[O1:%.*]] = or i1 [[R1]], [[R2]] 1042; CHECK-NEXT: [[O2:%.*]] = or i1 [[R3]], [[R4]] 1043; CHECK-NEXT: [[O3:%.*]] = or i1 [[O1]], [[O2]] 1044; CHECK-NEXT: ret i1 [[O3]] 1045; 1046 %r1 = call i1 @f_fcmp(float %fa, float %fb) 1047 %r2 = call i1 @d_fcmp(double %da, double %db) 1048 %r3 = call i1 @dp_icmp(double* %dpa, double* %dpb) 1049 %r4 = call i1 @ip_icmp(i8* %ipa, i8* %ipb) 1050 %o1 = or i1 %r1, %r2 1051 %o2 = or i1 %r3, %r4 1052 %o3 = or i1 %o1, %o2 1053 ret i1 %o3 1054} 1055 1056define i8 @ret_two() { 1057; CHECK-LABEL: define {{[^@]+}}@ret_two() 1058; CHECK-NEXT: ret i8 2 1059; 1060 ret i8 2 1061} 1062define i8 @ret_undef() { 1063; CHECK-LABEL: define {{[^@]+}}@ret_undef() 1064; CHECK-NEXT: ret i8 undef 1065; 1066 ret i8 undef 1067} 1068 1069; Verify we collapse undef to a value and return something non-undef here. 1070define i8 @undef_collapse_1() { 1071; CHECK-LABEL: define {{[^@]+}}@undef_collapse_1() 1072; CHECK-NEXT: ret i8 0 1073; 1074 %c = call i8 @ret_undef() 1075 %s = shl i8 %c, 2 1076 ret i8 %s 1077} 1078 1079; Verify we collapse undef to a value and return something non-undef here. 1080define i8 @undef_collapse_2() { 1081; CHECK-LABEL: define {{[^@]+}}@undef_collapse_2() 1082; CHECK-NEXT: ret i8 0 1083; 1084 %c = call i8 @ret_two() 1085 %s = shl i8 undef, %c 1086 ret i8 %s 1087} 1088 1089define i8 @undef_collapse_caller() { 1090; OLD_PM-LABEL: define {{[^@]+}}@undef_collapse_caller() 1091; OLD_PM-NEXT: ret i8 0 1092; 1093; NEW_PM-LABEL: define {{[^@]+}}@undef_collapse_caller() 1094; NEW_PM-NEXT: ret i8 0 1095; 1096; CGSCC_OLD_PM-LABEL: define {{[^@]+}}@undef_collapse_caller() 1097; CGSCC_OLD_PM-NEXT: [[C1:%.*]] = call i8 @undef_collapse_1() 1098; CGSCC_OLD_PM-NEXT: [[C2:%.*]] = call i8 @undef_collapse_2() 1099; CGSCC_OLD_PM-NEXT: [[A:%.*]] = add i8 [[C1]], [[C2]] 1100; CGSCC_OLD_PM-NEXT: ret i8 [[A]] 1101; 1102; CGSCC_NEW_PM-LABEL: define {{[^@]+}}@undef_collapse_caller() 1103; CGSCC_NEW_PM-NEXT: [[C1:%.*]] = call i8 @undef_collapse_1() 1104; CGSCC_NEW_PM-NEXT: [[C2:%.*]] = call i8 @undef_collapse_2() 1105; CGSCC_NEW_PM-NEXT: [[A:%.*]] = add i8 [[C1]], [[C2]] 1106; CGSCC_NEW_PM-NEXT: ret i8 [[A]] 1107; 1108 %c1 = call i8 @undef_collapse_1() 1109 %c2 = call i8 @undef_collapse_2() 1110 %a = add i8 %c1, %c2 1111 ret i8 %a 1112} 1113 1114define i32 @ret1or2(i1 %c) { 1115; CHECK-LABEL: define {{[^@]+}}@ret1or2 1116; CHECK-SAME: (i1 [[C:%.*]]) 1117; CHECK-NEXT: [[S:%.*]] = select i1 [[C]], i32 1, i32 2 1118; CHECK-NEXT: ret i32 [[S]] 1119; 1120 %s = select i1 %c, i32 1, i32 2 1121 ret i32 %s 1122} 1123define i1 @callee_range_1(i1 %c1, i1 %c2, i1 %c3) { 1124; OLD_PM-LABEL: define {{[^@]+}}@callee_range_1 1125; OLD_PM-SAME: (i1 [[C1:%.*]], i1 [[C2:%.*]], i1 [[C3:%.*]]) 1126; OLD_PM-NEXT: ret i1 true 1127; 1128; NEW_PM-LABEL: define {{[^@]+}}@callee_range_1 1129; NEW_PM-SAME: (i1 [[C1:%.*]], i1 [[C2:%.*]], i1 [[C3:%.*]]) 1130; NEW_PM-NEXT: ret i1 true 1131; 1132; CGSCC_OLD_PM-LABEL: define {{[^@]+}}@callee_range_1 1133; CGSCC_OLD_PM-SAME: (i1 [[C1:%.*]], i1 [[C2:%.*]], i1 [[C3:%.*]]) 1134; CGSCC_OLD_PM-NEXT: [[R1:%.*]] = call i32 @ret1or2(i1 [[C1]]) 1135; CGSCC_OLD_PM-NEXT: [[R2:%.*]] = call i32 @ret1or2(i1 [[C2]]) 1136; CGSCC_OLD_PM-NEXT: [[INDIRECTION:%.*]] = select i1 [[C3]], i32 [[R1]], i32 [[R2]] 1137; CGSCC_OLD_PM-NEXT: [[A:%.*]] = add i32 [[R1]], [[INDIRECTION]] 1138; CGSCC_OLD_PM-NEXT: [[I1:%.*]] = icmp sle i32 [[A]], 4 1139; CGSCC_OLD_PM-NEXT: [[I2:%.*]] = icmp sge i32 [[A]], 2 1140; CGSCC_OLD_PM-NEXT: [[F:%.*]] = and i1 [[I1]], [[I2]] 1141; CGSCC_OLD_PM-NEXT: ret i1 [[F]] 1142; 1143; CGSCC_NEW_PM-LABEL: define {{[^@]+}}@callee_range_1 1144; CGSCC_NEW_PM-SAME: (i1 [[C1:%.*]], i1 [[C2:%.*]], i1 [[C3:%.*]]) 1145; CGSCC_NEW_PM-NEXT: [[R1:%.*]] = call i32 @ret1or2(i1 [[C1]]) 1146; CGSCC_NEW_PM-NEXT: [[R2:%.*]] = call i32 @ret1or2(i1 [[C2]]) 1147; CGSCC_NEW_PM-NEXT: [[INDIRECTION:%.*]] = select i1 [[C3]], i32 [[R1]], i32 [[R2]] 1148; CGSCC_NEW_PM-NEXT: [[A:%.*]] = add i32 [[R1]], [[INDIRECTION]] 1149; CGSCC_NEW_PM-NEXT: [[I1:%.*]] = icmp sle i32 [[A]], 4 1150; CGSCC_NEW_PM-NEXT: [[I2:%.*]] = icmp sge i32 [[A]], 2 1151; CGSCC_NEW_PM-NEXT: [[F:%.*]] = and i1 [[I1]], [[I2]] 1152; CGSCC_NEW_PM-NEXT: ret i1 [[F]] 1153; 1154 %r1 = call i32 @ret1or2(i1 %c1) 1155 %r2 = call i32 @ret1or2(i1 %c2) 1156 %indirection = select i1 %c3, i32 %r1, i32 %r2 1157 %a = add i32 %r1, %indirection 1158 %i1 = icmp sle i32 %a, 4 1159 %i2 = icmp sge i32 %a, 2 1160 %f = and i1 %i1, %i2 1161 ret i1 %f 1162} 1163 1164define i1 @callee_range_2(i1 %c1, i1 %c2) { 1165; OLD_PM-LABEL: define {{[^@]+}}@callee_range_2 1166; OLD_PM-SAME: (i1 [[C1:%.*]], i1 [[C2:%.*]]) 1167; OLD_PM-NEXT: [[R1:%.*]] = call i32 @ret1or2(i1 [[C1]]) #2, !range !4 1168; OLD_PM-NEXT: [[R2:%.*]] = call i32 @ret1or2(i1 [[C2]]) #3, !range !4 1169; OLD_PM-NEXT: [[A:%.*]] = add i32 [[R1]], [[R2]] 1170; OLD_PM-NEXT: [[I1:%.*]] = icmp sle i32 [[A]], 3 1171; OLD_PM-NEXT: [[I2:%.*]] = icmp sge i32 [[A]], 2 1172; OLD_PM-NEXT: [[F:%.*]] = and i1 [[I1]], [[I2]] 1173; OLD_PM-NEXT: ret i1 [[F]] 1174; 1175; NEW_PM-LABEL: define {{[^@]+}}@callee_range_2 1176; NEW_PM-SAME: (i1 [[C1:%.*]], i1 [[C2:%.*]]) 1177; NEW_PM-NEXT: [[R1:%.*]] = call i32 @ret1or2(i1 [[C1]]) #2, !range !5 1178; NEW_PM-NEXT: [[R2:%.*]] = call i32 @ret1or2(i1 [[C2]]) #3, !range !5 1179; NEW_PM-NEXT: [[A:%.*]] = add i32 [[R1]], [[R2]] 1180; NEW_PM-NEXT: [[I1:%.*]] = icmp sle i32 [[A]], 3 1181; NEW_PM-NEXT: [[I2:%.*]] = icmp sge i32 [[A]], 2 1182; NEW_PM-NEXT: [[F:%.*]] = and i1 [[I1]], [[I2]] 1183; NEW_PM-NEXT: ret i1 [[F]] 1184; 1185; CGSCC_OLD_PM-LABEL: define {{[^@]+}}@callee_range_2 1186; CGSCC_OLD_PM-SAME: (i1 [[C1:%.*]], i1 [[C2:%.*]]) 1187; CGSCC_OLD_PM-NEXT: [[R1:%.*]] = call i32 @ret1or2(i1 [[C1]]) 1188; CGSCC_OLD_PM-NEXT: [[R2:%.*]] = call i32 @ret1or2(i1 [[C2]]) 1189; CGSCC_OLD_PM-NEXT: [[A:%.*]] = add i32 [[R1]], [[R2]] 1190; CGSCC_OLD_PM-NEXT: [[I1:%.*]] = icmp sle i32 [[A]], 3 1191; CGSCC_OLD_PM-NEXT: [[I2:%.*]] = icmp sge i32 [[A]], 2 1192; CGSCC_OLD_PM-NEXT: [[F:%.*]] = and i1 [[I1]], [[I2]] 1193; CGSCC_OLD_PM-NEXT: ret i1 [[F]] 1194; 1195; CGSCC_NEW_PM-LABEL: define {{[^@]+}}@callee_range_2 1196; CGSCC_NEW_PM-SAME: (i1 [[C1:%.*]], i1 [[C2:%.*]]) 1197; CGSCC_NEW_PM-NEXT: [[R1:%.*]] = call i32 @ret1or2(i1 [[C1]]) 1198; CGSCC_NEW_PM-NEXT: [[R2:%.*]] = call i32 @ret1or2(i1 [[C2]]) 1199; CGSCC_NEW_PM-NEXT: [[A:%.*]] = add i32 [[R1]], [[R2]] 1200; CGSCC_NEW_PM-NEXT: [[I1:%.*]] = icmp sle i32 [[A]], 3 1201; CGSCC_NEW_PM-NEXT: [[I2:%.*]] = icmp sge i32 [[A]], 2 1202; CGSCC_NEW_PM-NEXT: [[F:%.*]] = and i1 [[I1]], [[I2]] 1203; CGSCC_NEW_PM-NEXT: ret i1 [[F]] 1204; 1205 %r1 = call i32 @ret1or2(i1 %c1) 1206 %r2 = call i32 @ret1or2(i1 %c2) 1207 %a = add i32 %r1, %r2 1208 %i1 = icmp sle i32 %a, 3 1209 %i2 = icmp sge i32 %a, 2 1210 %f = and i1 %i1, %i2 1211 ret i1 %f 1212} 1213 1214 1215define i32 @ret100() { 1216; CHECK-LABEL: define {{[^@]+}}@ret100() 1217; CHECK-NEXT: ret i32 100 1218; 1219 ret i32 100 1220} 1221 1222define i1 @ctx_adjustment(i32 %V) { 1223; OLD_PM-LABEL: define {{[^@]+}}@ctx_adjustment 1224; OLD_PM-SAME: (i32 [[V:%.*]]) 1225; OLD_PM-NEXT: [[C1:%.*]] = icmp sge i32 [[V]], 100 1226; OLD_PM-NEXT: br i1 [[C1]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]] 1227; OLD_PM: if.true: 1228; OLD_PM-NEXT: br label [[END:%.*]] 1229; OLD_PM: if.false: 1230; OLD_PM-NEXT: br label [[END]] 1231; OLD_PM: end: 1232; OLD_PM-NEXT: [[PHI:%.*]] = phi i32 [ [[V]], [[IF_TRUE]] ], [ 100, [[IF_FALSE]] ] 1233; OLD_PM-NEXT: [[C2:%.*]] = icmp sge i32 [[PHI]], 100 1234; OLD_PM-NEXT: ret i1 [[C2]] 1235; 1236; NEW_PM-LABEL: define {{[^@]+}}@ctx_adjustment 1237; NEW_PM-SAME: (i32 [[V:%.*]]) 1238; NEW_PM-NEXT: [[C1:%.*]] = icmp sge i32 [[V]], 100 1239; NEW_PM-NEXT: br i1 [[C1]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]] 1240; NEW_PM: if.true: 1241; NEW_PM-NEXT: br label [[END:%.*]] 1242; NEW_PM: if.false: 1243; NEW_PM-NEXT: br label [[END]] 1244; NEW_PM: end: 1245; NEW_PM-NEXT: ret i1 true 1246; 1247; CGSCC_OLD_PM-LABEL: define {{[^@]+}}@ctx_adjustment 1248; CGSCC_OLD_PM-SAME: (i32 [[V:%.*]]) 1249; CGSCC_OLD_PM-NEXT: [[C1:%.*]] = icmp sge i32 [[V]], 100 1250; CGSCC_OLD_PM-NEXT: br i1 [[C1]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]] 1251; CGSCC_OLD_PM: if.true: 1252; CGSCC_OLD_PM-NEXT: br label [[END:%.*]] 1253; CGSCC_OLD_PM: if.false: 1254; CGSCC_OLD_PM-NEXT: br label [[END]] 1255; CGSCC_OLD_PM: end: 1256; CGSCC_OLD_PM-NEXT: [[PHI:%.*]] = phi i32 [ [[V]], [[IF_TRUE]] ], [ 100, [[IF_FALSE]] ] 1257; CGSCC_OLD_PM-NEXT: [[C2:%.*]] = icmp sge i32 [[PHI]], 100 1258; CGSCC_OLD_PM-NEXT: ret i1 [[C2]] 1259; 1260; CGSCC_NEW_PM-LABEL: define {{[^@]+}}@ctx_adjustment 1261; CGSCC_NEW_PM-SAME: (i32 [[V:%.*]]) 1262; CGSCC_NEW_PM-NEXT: [[C1:%.*]] = icmp sge i32 [[V]], 100 1263; CGSCC_NEW_PM-NEXT: br i1 [[C1]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]] 1264; CGSCC_NEW_PM: if.true: 1265; CGSCC_NEW_PM-NEXT: br label [[END:%.*]] 1266; CGSCC_NEW_PM: if.false: 1267; CGSCC_NEW_PM-NEXT: br label [[END]] 1268; CGSCC_NEW_PM: end: 1269; CGSCC_NEW_PM-NEXT: ret i1 true 1270; 1271 %c1 = icmp sge i32 %V, 100 1272 br i1 %c1, label %if.true, label %if.false 1273if.true: 1274 br label %end 1275if.false: 1276 %call = call i32 @ret100() 1277 br label %end 1278end: 1279 %phi = phi i32 [ %V, %if.true ], [ %call, %if.false ] 1280 %c2 = icmp sge i32 %phi, 100 1281 ret i1 %c2 1282} 1283 1284 1285!0 = !{i32 0, i32 10} 1286!1 = !{i32 10, i32 100} 1287; CHECK: !0 = !{i32 0, i32 10} 1288; CHECK-NEXT: !1 = !{i32 10, i32 100} 1289; NEW_PM: !2 = !{i32 200, i32 1091} 1290; OLD_PM: !3 = !{i32 0, i32 2} 1291; NEW_PM: !3 = !{i32 1, i32 -2147483648} 1292; NEW_PM: !4 = !{i32 0, i32 2} 1293