brintos

brintos / llvm-project-archived public Read only

0
0
Text · 19.2 KiB · db4965b Raw
418 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt < %s -S -passes=instcombine | FileCheck %s3@A = extern_weak global float, align 44 5; %same.as.v1 is a select with two phis %v1 and %phi.to.remove as the true6; and false values, while %v1 and %phi.to.remove are actually the same.7; Fold the selection instruction %same.as.v1 to %v1.8define void @select_with_identical_phi(ptr %m, ptr %n, i32 %count) {9; CHECK-LABEL: @select_with_identical_phi(10; CHECK-NEXT:  entry:11; CHECK-NEXT:    br label [[FOR_BODY:%.*]]12; CHECK:       for.body:13; CHECK-NEXT:    [[V0:%.*]] = phi float [ 0x4415AF1D80000000, [[ENTRY:%.*]] ], [ [[V0_1:%.*]], [[FOR_BODY]] ]14; CHECK-NEXT:    [[V1:%.*]] = phi float [ 0xC415AF1D80000000, [[ENTRY]] ], [ [[V1_1:%.*]], [[FOR_BODY]] ]15; CHECK-NEXT:    [[I:%.*]] = phi i32 [ 0, [[ENTRY]] ], [ [[INC_I:%.*]], [[FOR_BODY]] ]16; CHECK-NEXT:    [[Q:%.*]] = phi ptr [ [[M:%.*]], [[ENTRY]] ], [ [[Q_NEXT:%.*]], [[FOR_BODY]] ]17; CHECK-NEXT:    [[C:%.*]] = phi ptr [ [[N:%.*]], [[ENTRY]] ], [ [[C_NEXT:%.*]], [[FOR_BODY]] ]18; CHECK-NEXT:    [[Q_LOAD:%.*]] = load float, ptr [[Q]], align 419; CHECK-NEXT:    [[C_LOAD:%.*]] = load float, ptr [[C]], align 420; CHECK-NEXT:    [[SUB:%.*]] = fsub float [[Q_LOAD]], [[C_LOAD]]21; CHECK-NEXT:    [[CMP1:%.*]] = fcmp olt float [[SUB]], [[V0]]22; CHECK-NEXT:    [[V0_1]] = select i1 [[CMP1]], float [[SUB]], float [[V0]]23; CHECK-NEXT:    [[CMP2:%.*]] = fcmp ogt float [[SUB]], [[V1]]24; CHECK-NEXT:    [[V1_1]] = select i1 [[CMP2]], float [[SUB]], float [[V1]]25; CHECK-NEXT:    [[INC_I]] = add nuw nsw i32 [[I]], 126; CHECK-NEXT:    [[Q_NEXT]] = getelementptr inbounds nuw i8, ptr [[Q]], i64 427; CHECK-NEXT:    [[C_NEXT]] = getelementptr inbounds nuw i8, ptr [[C]], i64 428; CHECK-NEXT:    [[EXITCOND:%.*]] = icmp eq i32 [[INC_I]], [[COUNT:%.*]]29; CHECK-NEXT:    br i1 [[EXITCOND]], label [[EXIT:%.*]], label [[FOR_BODY]]30; CHECK:       exit:31; CHECK-NEXT:    store float [[V1_1]], ptr @A, align 432; CHECK-NEXT:    ret void33;34entry:35  br label %for.body36 37for.body:                                    ; preds = %entry, %for.body38  %v0 = phi float [ 0x4415AF1D80000000, %entry ], [ %v0.1, %for.body ]39  %v1 = phi float [ 0xC415AF1D80000000, %entry ], [ %v1.1, %for.body ]40  %phi.to.remove = phi float [ 0xC415AF1D80000000, %entry ], [ %phi.to.remove.next, %for.body ]41  %i = phi i32 [ 0, %entry ], [ %inc.i, %for.body ]42  %q = phi ptr [ %m, %entry ], [ %q.next, %for.body ]43  %c = phi ptr [ %n, %entry ], [ %c.next, %for.body ]44  %q.load = load float, ptr %q45  %c.load = load float, ptr %c46  %sub = fsub float %q.load, %c.load47  %cmp1 = fcmp olt float %sub, %v048  %v0.1 = select i1 %cmp1, float %sub, float %v049  %same.as.v1 = select i1 %cmp1, float %v1, float %phi.to.remove50  %cmp2 = fcmp ogt float  %sub, %same.as.v151  %v1.1 = select i1 %cmp2, float %sub, float %v152  %phi.to.remove.next = select i1 %cmp2, float %sub, float %same.as.v153  %inc.i = add nuw nsw i32 %i, 154  %q.next = getelementptr inbounds i8, ptr %q, i64 455  %c.next = getelementptr inbounds i8, ptr %c, i64 456  %exitcond = icmp eq i32 %inc.i, %count57  br i1 %exitcond, label %exit, label %for.body58 59exit:60  %vl.1.lcssa = phi float [ %v1.1, %for.body ]61  store float %vl.1.lcssa, ptr @A62  ret void63}64 65; Reduced from select_with_identical_phi().66; Check that %same.as.v1 can be folded.67define void @select_with_identical_phi_2(i1 %cmp1, i1 %cmp2, float %x) {68; CHECK-LABEL: @select_with_identical_phi_2(69; CHECK-NEXT:  entry:70; CHECK-NEXT:    br label [[FOR_BODY:%.*]]71; CHECK:       for.body:72; CHECK-NEXT:    [[V1:%.*]] = phi float [ 0xC415AF1D80000000, [[ENTRY:%.*]] ], [ [[V1_1:%.*]], [[FOR_BODY]] ]73; CHECK-NEXT:    [[I:%.*]] = phi i32 [ 0, [[ENTRY]] ], [ [[INC_I:%.*]], [[FOR_BODY]] ]74; CHECK-NEXT:    [[V1_1]] = select i1 [[CMP2:%.*]], float [[X:%.*]], float [[V1]]75; CHECK-NEXT:    [[INC_I]] = add nuw nsw i32 [[I]], 176; CHECK-NEXT:    [[EXITCOND:%.*]] = icmp eq i32 [[INC_I]], 10077; CHECK-NEXT:    br i1 [[EXITCOND]], label [[EXIT:%.*]], label [[FOR_BODY]]78; CHECK:       exit:79; CHECK-NEXT:    store float [[V1_1]], ptr @A, align 480; CHECK-NEXT:    ret void81;82entry:83  br label %for.body84 85for.body:                                    ; preds = %entry, %for.body86  %v1 = phi float [ 0xC415AF1D80000000, %entry ], [ %v1.1, %for.body ]87  %phi.to.remove = phi float [ 0xC415AF1D80000000, %entry ], [ %phi.to.remove.next, %for.body ]88  %i = phi i32 [ 0, %entry ], [ %inc.i, %for.body ]89  %same.as.v1 = select i1 %cmp1, float %v1, float %phi.to.remove90  %v1.1 = select i1 %cmp2, float %x, float %v191  %phi.to.remove.next = select i1 %cmp2, float %x, float %same.as.v192  %inc.i = add nuw nsw i32 %i, 193  %exitcond = icmp eq i32 %inc.i, 10094  br i1 %exitcond, label %exit, label %for.body95 96exit:97  %vl.1.lcssa = phi float [ %v1.1, %for.body ]98  store float %vl.1.lcssa, ptr @A99  ret void100}101 102; The difference from select_with_identical_phi_2() is that the true and false values in103; %phi.to.remove.next and %v1.1 are swapped.104; Check that %same.as.v1 can be folded.105define void @select_with_identical_phi_3(i1 %cmp1, i1 %cmp2, float %x) {106; CHECK-LABEL: @select_with_identical_phi_3(107; CHECK-NEXT:  entry:108; CHECK-NEXT:    br label [[FOR_BODY:%.*]]109; CHECK:       for.body:110; CHECK-NEXT:    [[V1:%.*]] = phi float [ 0xC415AF1D80000000, [[ENTRY:%.*]] ], [ [[V1_1:%.*]], [[FOR_BODY]] ]111; CHECK-NEXT:    [[I:%.*]] = phi i32 [ 0, [[ENTRY]] ], [ [[INC_I:%.*]], [[FOR_BODY]] ]112; CHECK-NEXT:    [[V1_1]] = select i1 [[CMP2:%.*]], float [[V1]], float [[X:%.*]]113; CHECK-NEXT:    [[INC_I]] = add nuw nsw i32 [[I]], 1114; CHECK-NEXT:    [[EXITCOND:%.*]] = icmp eq i32 [[INC_I]], 100115; CHECK-NEXT:    br i1 [[EXITCOND]], label [[EXIT:%.*]], label [[FOR_BODY]]116; CHECK:       exit:117; CHECK-NEXT:    store float [[V1_1]], ptr @A, align 4118; CHECK-NEXT:    ret void119;120entry:121  br label %for.body122 123for.body:                                    ; preds = %entry, %for.body124  %v1 = phi float [ 0xC415AF1D80000000, %entry ], [ %v1.1, %for.body ]125  %phi.to.remove = phi float [ 0xC415AF1D80000000, %entry ], [ %phi.to.remove.next, %for.body ]126  %i = phi i32 [ 0, %entry ], [ %inc.i, %for.body ]127  %same.as.v1 = select i1 %cmp1, float %v1, float %phi.to.remove128  %v1.1 = select i1 %cmp2, float %v1, float %x129  %phi.to.remove.next = select i1 %cmp2, float %same.as.v1, float %x130  %inc.i = add nuw nsw i32 %i, 1131  %exitcond = icmp eq i32 %inc.i, 100132  br i1 %exitcond, label %exit, label %for.body133 134exit:135  %vl.1.lcssa = phi float [ %v1.1, %for.body ]136  store float %vl.1.lcssa, ptr @A137  ret void138}139 140; The difference from select_with_identical_phi_2() is that the true and false values in141; same.as.v1 are swapped.142; Check that %same.as.v1 can be folded.143define void @select_with_identical_phi_4(i1 %cmp1, i1 %cmp2, float %x) {144; CHECK-LABEL: @select_with_identical_phi_4(145; CHECK-NEXT:  entry:146; CHECK-NEXT:    br label [[FOR_BODY:%.*]]147; CHECK:       for.body:148; CHECK-NEXT:    [[V1:%.*]] = phi float [ 0xC415AF1D80000000, [[ENTRY:%.*]] ], [ [[V1_1:%.*]], [[FOR_BODY]] ]149; CHECK-NEXT:    [[I:%.*]] = phi i32 [ 0, [[ENTRY]] ], [ [[INC_I:%.*]], [[FOR_BODY]] ]150; CHECK-NEXT:    [[V1_1]] = select i1 [[CMP2:%.*]], float [[X:%.*]], float [[V1]]151; CHECK-NEXT:    [[INC_I]] = add nuw nsw i32 [[I]], 1152; CHECK-NEXT:    [[EXITCOND:%.*]] = icmp eq i32 [[INC_I]], 100153; CHECK-NEXT:    br i1 [[EXITCOND]], label [[EXIT:%.*]], label [[FOR_BODY]]154; CHECK:       exit:155; CHECK-NEXT:    store float [[V1_1]], ptr @A, align 4156; CHECK-NEXT:    ret void157;158entry:159  br label %for.body160 161for.body:                                    ; preds = %entry, %for.body162  %v1 = phi float [ 0xC415AF1D80000000, %entry ], [ %v1.1, %for.body ]163  %phi.to.remove = phi float [ 0xC415AF1D80000000, %entry ], [ %phi.to.remove.next, %for.body ]164  %i = phi i32 [ 0, %entry ], [ %inc.i, %for.body ]165  %same.as.v1 = select i1 %cmp1, float %phi.to.remove, float %v1166  %v1.1 = select i1 %cmp2, float %x, float %v1167  %phi.to.remove.next = select i1 %cmp2, float %x, float %same.as.v1168  %inc.i = add nuw nsw i32 %i, 1169  %exitcond = icmp eq i32 %inc.i, 100170  br i1 %exitcond, label %exit, label %for.body171 172exit:173  %vl.1.lcssa = phi float [ %v1.1, %for.body ]174  store float %vl.1.lcssa, ptr @A175  ret void176}177 178; The difference from select_with_identical_phi() is that the true and false values in179; %same.as.v1, %phi.to.remove.next and %v1.1 are swapped.180; Check that %same.as.v1 can be folded.181define void @select_with_identical_phi_5(i1 %cmp1, i1 %cmp2, float %x) {182; CHECK-LABEL: @select_with_identical_phi_5(183; CHECK-NEXT:  entry:184; CHECK-NEXT:    br label [[FOR_BODY:%.*]]185; CHECK:       for.body:186; CHECK-NEXT:    [[V1:%.*]] = phi float [ 0xC415AF1D80000000, [[ENTRY:%.*]] ], [ [[V1_1:%.*]], [[FOR_BODY]] ]187; CHECK-NEXT:    [[I:%.*]] = phi i32 [ 0, [[ENTRY]] ], [ [[INC_I:%.*]], [[FOR_BODY]] ]188; CHECK-NEXT:    [[V1_1]] = select i1 [[CMP2:%.*]], float [[V1]], float [[X:%.*]]189; CHECK-NEXT:    [[INC_I]] = add nuw nsw i32 [[I]], 1190; CHECK-NEXT:    [[EXITCOND:%.*]] = icmp eq i32 [[INC_I]], 100191; CHECK-NEXT:    br i1 [[EXITCOND]], label [[EXIT:%.*]], label [[FOR_BODY]]192; CHECK:       exit:193; CHECK-NEXT:    store float [[V1_1]], ptr @A, align 4194; CHECK-NEXT:    ret void195;196entry:197  br label %for.body198 199for.body:                                    ; preds = %entry, %for.body200  %v1 = phi float [ 0xC415AF1D80000000, %entry ], [ %v1.1, %for.body ]201  %phi.to.remove = phi float [ 0xC415AF1D80000000, %entry ], [ %phi.to.remove.next, %for.body ]202  %i = phi i32 [ 0, %entry ], [ %inc.i, %for.body ]203  %same.as.v1 = select i1 %cmp1, float %phi.to.remove, float %v1204  %v1.1 = select i1 %cmp2, float %v1, float %x205  %phi.to.remove.next = select i1 %cmp2, float %same.as.v1, float %x206  %inc.i = add nuw nsw i32 %i, 1207  %exitcond = icmp eq i32 %inc.i, 100208  br i1 %exitcond, label %exit, label %for.body209 210exit:211  %vl.1.lcssa = phi float [ %v1.1, %for.body ]212  store float %vl.1.lcssa, ptr @A213  ret void214}215 216; The difference from select_with_identical_phi_2() is that not all phis are sorted with217; the same order of incoming BBs.218; Check that %same.as.v1 can be folded.219define void @select_with_identical_phi_6(i1 %cmp1, i1 %cmp2, float %x) {220; CHECK-LABEL: @select_with_identical_phi_6(221; CHECK-NEXT:  entry:222; CHECK-NEXT:    br label [[FOR_BODY:%.*]]223; CHECK:       for.body:224; CHECK-NEXT:    [[V1:%.*]] = phi float [ 0xC415AF1D80000000, [[ENTRY:%.*]] ], [ [[V1_1:%.*]], [[FOR_BODY]] ]225; CHECK-NEXT:    [[I:%.*]] = phi i32 [ 0, [[ENTRY]] ], [ [[INC_I:%.*]], [[FOR_BODY]] ]226; CHECK-NEXT:    [[V1_1]] = select i1 [[CMP2:%.*]], float [[X:%.*]], float [[V1]]227; CHECK-NEXT:    [[INC_I]] = add nuw nsw i32 [[I]], 1228; CHECK-NEXT:    [[EXITCOND:%.*]] = icmp eq i32 [[INC_I]], 100229; CHECK-NEXT:    br i1 [[EXITCOND]], label [[EXIT:%.*]], label [[FOR_BODY]]230; CHECK:       exit:231; CHECK-NEXT:    store float [[V1_1]], ptr @A, align 4232; CHECK-NEXT:    ret void233;234entry:235  br label %for.body236 237for.body:                                    ; preds = %entry, %for.body238  %v1 = phi float [ 0xC415AF1D80000000, %entry ], [ %v1.1, %for.body ]239  %phi.to.remove = phi float [ %phi.to.remove.next, %for.body ], [ 0xC415AF1D80000000, %entry ]240  %i = phi i32 [ 0, %entry ], [ %inc.i, %for.body ]241  %same.as.v1 = select i1 %cmp1, float %v1, float %phi.to.remove242  %v1.1 = select i1 %cmp2, float %x, float %v1243  %phi.to.remove.next = select i1 %cmp2, float %x, float %same.as.v1244  %inc.i = add nuw nsw i32 %i, 1245  %exitcond = icmp eq i32 %inc.i, 100246  br i1 %exitcond, label %exit, label %for.body247 248exit:249  %vl.1.lcssa = phi float [ %v1.1, %for.body ]250  store float %vl.1.lcssa, ptr @A251  ret void252}253 254; %v1 and %phi.to.remove do not have the same start value.255; Cannot fold %same.as.v1.256define void @select_with_identical_phi_negative_1(i1 %cmp1, i1 %cmp2, float %x) {257; CHECK-LABEL: @select_with_identical_phi_negative_1(258; CHECK-NEXT:  entry:259; CHECK-NEXT:    br label [[FOR_BODY:%.*]]260; CHECK:       for.body:261; CHECK-NEXT:    [[V1:%.*]] = phi float [ 0x4415AF1D80000000, [[ENTRY:%.*]] ], [ [[V1_1:%.*]], [[FOR_BODY]] ]262; CHECK-NEXT:    [[PHI_TO_REMOVE:%.*]] = phi float [ 0xC415AF1D80000000, [[ENTRY]] ], [ [[PHI_TO_REMOVE_NEXT:%.*]], [[FOR_BODY]] ]263; CHECK-NEXT:    [[I:%.*]] = phi i32 [ 0, [[ENTRY]] ], [ [[INC_I:%.*]], [[FOR_BODY]] ]264; CHECK-NEXT:    [[SAME_AS_V1:%.*]] = select i1 [[CMP1:%.*]], float [[V1]], float [[PHI_TO_REMOVE]]265; CHECK-NEXT:    [[V1_1]] = select i1 [[CMP2:%.*]], float [[X:%.*]], float [[V1]]266; CHECK-NEXT:    [[PHI_TO_REMOVE_NEXT]] = select i1 [[CMP2]], float [[X]], float [[SAME_AS_V1]]267; CHECK-NEXT:    [[INC_I]] = add nuw nsw i32 [[I]], 1268; CHECK-NEXT:    [[EXITCOND:%.*]] = icmp eq i32 [[INC_I]], 100269; CHECK-NEXT:    br i1 [[EXITCOND]], label [[EXIT:%.*]], label [[FOR_BODY]]270; CHECK:       exit:271; CHECK-NEXT:    store float [[V1_1]], ptr @A, align 4272; CHECK-NEXT:    ret void273;274entry:275  br label %for.body276 277for.body:                                    ; preds = %entry, %for.body278  %v1 = phi float [ 0x4415AF1D80000000, %entry ], [ %v1.1, %for.body ]279  %phi.to.remove = phi float [ 0xC415AF1D80000000, %entry ], [ %phi.to.remove.next, %for.body ]280  %i = phi i32 [ 0, %entry ], [ %inc.i, %for.body ]281  %same.as.v1 = select i1 %cmp1, float %v1, float %phi.to.remove282  %v1.1 = select i1 %cmp2, float %x, float %v1283  %phi.to.remove.next = select i1 %cmp2, float %x, float %same.as.v1284  %inc.i = add nuw nsw i32 %i, 1285  %exitcond = icmp eq i32 %inc.i, 100286  br i1 %exitcond, label %exit, label %for.body287 288exit:289  %vl.1.lcssa = phi float [ %v1.1, %for.body ]290  store float %vl.1.lcssa, ptr @A291  ret void292}293 294; %v1 and %phi.to.remove do not act as the same phi since %v1.1 and %phi.to.remove.next do not evolve the same.295; Cannot fold %same.as.v1.296define void @select_with_identical_phi_negative_2(i1 %cmp1, i1 %cmp2, float %x) {297; CHECK-LABEL: @select_with_identical_phi_negative_2(298; CHECK-NEXT:  entry:299; CHECK-NEXT:    br label [[FOR_BODY:%.*]]300; CHECK:       for.body:301; CHECK-NEXT:    [[V1:%.*]] = phi float [ 0xC415AF1D80000000, [[ENTRY:%.*]] ], [ [[V1_1:%.*]], [[FOR_BODY]] ]302; CHECK-NEXT:    [[PHI_TO_REMOVE:%.*]] = phi float [ 0xC415AF1D80000000, [[ENTRY]] ], [ [[PHI_TO_REMOVE_NEXT:%.*]], [[FOR_BODY]] ]303; CHECK-NEXT:    [[I:%.*]] = phi i32 [ 0, [[ENTRY]] ], [ [[INC_I:%.*]], [[FOR_BODY]] ]304; CHECK-NEXT:    [[SAME_AS_V1:%.*]] = select i1 [[CMP1:%.*]], float [[V1]], float [[PHI_TO_REMOVE]]305; CHECK-NEXT:    [[V1_1]] = select i1 [[CMP2:%.*]], float [[V1]], float [[X:%.*]]306; CHECK-NEXT:    [[PHI_TO_REMOVE_NEXT]] = select i1 [[CMP2]], float [[X]], float [[SAME_AS_V1]]307; CHECK-NEXT:    [[INC_I]] = add nuw nsw i32 [[I]], 1308; CHECK-NEXT:    [[EXITCOND:%.*]] = icmp eq i32 [[INC_I]], 100309; CHECK-NEXT:    br i1 [[EXITCOND]], label [[EXIT:%.*]], label [[FOR_BODY]]310; CHECK:       exit:311; CHECK-NEXT:    store float [[V1_1]], ptr @A, align 4312; CHECK-NEXT:    ret void313;314entry:315  br label %for.body316 317for.body:                                    ; preds = %entry, %for.body318  %v1 = phi float [ 0xC415AF1D80000000, %entry ], [ %v1.1, %for.body ]319  %phi.to.remove = phi float [ 0xC415AF1D80000000, %entry ], [ %phi.to.remove.next, %for.body ]320  %i = phi i32 [ 0, %entry ], [ %inc.i, %for.body ]321  %same.as.v1 = select i1 %cmp1, float %v1, float %phi.to.remove322  %v1.1 = select i1 %cmp2, float %v1, float %x323  %phi.to.remove.next = select i1 %cmp2, float %x, float %same.as.v1324  %inc.i = add nuw nsw i32 %i, 1325  %exitcond = icmp eq i32 %inc.i, 100326  br i1 %exitcond, label %exit, label %for.body327 328exit:329  %vl.1.lcssa = phi float [ %v1.1, %for.body ]330  store float %vl.1.lcssa, ptr @A331  ret void332}333 334; %v1 and %phi.to.remove do not act as the same phi since %v1.1 and %phi.to.remove.next do not335; have the same condition.336; Cannot fold %same.as.v1.337define void @select_with_identical_phi_negative_3(i1 %cmp1, i1 %cmp2, i1 %cmp3, float %x) {338; CHECK-LABEL: @select_with_identical_phi_negative_3(339; CHECK-NEXT:  entry:340; CHECK-NEXT:    br label [[FOR_BODY:%.*]]341; CHECK:       for.body:342; CHECK-NEXT:    [[V1:%.*]] = phi float [ 0xC415AF1D80000000, [[ENTRY:%.*]] ], [ [[V1_1:%.*]], [[FOR_BODY]] ]343; CHECK-NEXT:    [[PHI_TO_REMOVE:%.*]] = phi float [ 0xC415AF1D80000000, [[ENTRY]] ], [ [[PHI_TO_REMOVE_NEXT:%.*]], [[FOR_BODY]] ]344; CHECK-NEXT:    [[I:%.*]] = phi i32 [ 0, [[ENTRY]] ], [ [[INC_I:%.*]], [[FOR_BODY]] ]345; CHECK-NEXT:    [[SAME_AS_V1:%.*]] = select i1 [[CMP1:%.*]], float [[V1]], float [[PHI_TO_REMOVE]]346; CHECK-NEXT:    [[V1_1]] = select i1 [[CMP3:%.*]], float [[V1]], float [[X:%.*]]347; CHECK-NEXT:    [[PHI_TO_REMOVE_NEXT]] = select i1 [[CMP2:%.*]], float [[X]], float [[SAME_AS_V1]]348; CHECK-NEXT:    [[INC_I]] = add nuw nsw i32 [[I]], 1349; CHECK-NEXT:    [[EXITCOND:%.*]] = icmp eq i32 [[INC_I]], 100350; CHECK-NEXT:    br i1 [[EXITCOND]], label [[EXIT:%.*]], label [[FOR_BODY]]351; CHECK:       exit:352; CHECK-NEXT:    store float [[V1_1]], ptr @A, align 4353; CHECK-NEXT:    ret void354;355entry:356  br label %for.body357 358for.body:                                    ; preds = %entry, %for.body359  %v1 = phi float [ 0xC415AF1D80000000, %entry ], [ %v1.1, %for.body ]360  %phi.to.remove = phi float [ 0xC415AF1D80000000, %entry ], [ %phi.to.remove.next, %for.body ]361  %i = phi i32 [ 0, %entry ], [ %inc.i, %for.body ]362  %same.as.v1 = select i1 %cmp1, float %v1, float %phi.to.remove363  %v1.1 = select i1 %cmp3, float %v1, float %x364  %phi.to.remove.next = select i1 %cmp2, float %x, float %same.as.v1365  %inc.i = add nuw nsw i32 %i, 1366  %exitcond = icmp eq i32 %inc.i, 100367  br i1 %exitcond, label %exit, label %for.body368 369exit:370  %vl.1.lcssa = phi float [ %v1.1, %for.body ]371  store float %vl.1.lcssa, ptr @A372  ret void373}374 375; The true and false values of %same.as.v1 are not really the same phi.376; Cannot fold %same.as.v1.377define void @select_with_identical_phi_negative_4(i1 %cmp1, i1 %cmp2, float %x) {378; CHECK-LABEL: @select_with_identical_phi_negative_4(379; CHECK-NEXT:  entry:380; CHECK-NEXT:    br label [[FOR_BODY:%.*]]381; CHECK:       for.body:382; CHECK-NEXT:    [[V0:%.*]] = phi float [ 0x4415AF1D80000000, [[ENTRY:%.*]] ], [ [[V0_1:%.*]], [[FOR_BODY]] ]383; CHECK-NEXT:    [[V1:%.*]] = phi float [ 0xC415AF1D80000000, [[ENTRY]] ], [ [[V1_1:%.*]], [[FOR_BODY]] ]384; CHECK-NEXT:    [[PHI_TO_REMOVE:%.*]] = phi float [ 0xC415AF1D80000000, [[ENTRY]] ], [ [[PHI_TO_REMOVE_NEXT:%.*]], [[FOR_BODY]] ]385; CHECK-NEXT:    [[I:%.*]] = phi i32 [ 0, [[ENTRY]] ], [ [[INC_I:%.*]], [[FOR_BODY]] ]386; CHECK-NEXT:    [[SAME_AS_V1:%.*]] = select i1 [[CMP1:%.*]], float [[V0]], float [[PHI_TO_REMOVE]]387; CHECK-NEXT:    [[V1_1]] = select i1 [[CMP2:%.*]], float [[X:%.*]], float [[V1]]388; CHECK-NEXT:    [[PHI_TO_REMOVE_NEXT]] = select i1 [[CMP2]], float [[X]], float [[SAME_AS_V1]]389; CHECK-NEXT:    [[V0_1]] = fadd float [[V0]], 1.000000e+00390; CHECK-NEXT:    [[INC_I]] = add nuw nsw i32 [[I]], 1391; CHECK-NEXT:    [[EXITCOND:%.*]] = icmp eq i32 [[INC_I]], 100392; CHECK-NEXT:    br i1 [[EXITCOND]], label [[EXIT:%.*]], label [[FOR_BODY]]393; CHECK:       exit:394; CHECK-NEXT:    store float [[V1_1]], ptr @A, align 4395; CHECK-NEXT:    ret void396;397entry:398  br label %for.body399 400for.body:                                    ; preds = %entry, %for.body401  %v0 = phi float [ 0x4415AF1D80000000, %entry ], [ %v0.1, %for.body ]402  %v1 = phi float [ 0xC415AF1D80000000, %entry ], [ %v1.1, %for.body ]403  %phi.to.remove = phi float [ 0xC415AF1D80000000, %entry ], [ %phi.to.remove.next, %for.body ]404  %i = phi i32 [ 0, %entry ], [ %inc.i, %for.body ]405  %same.as.v1 = select i1 %cmp1, float %v0, float %phi.to.remove406  %v1.1 = select i1 %cmp2, float %x, float %v1407  %phi.to.remove.next = select i1 %cmp2, float %x, float %same.as.v1408  %v0.1 = fadd float %v0, 1.0409  %inc.i = add nuw nsw i32 %i, 1410  %exitcond = icmp eq i32 %inc.i, 100411  br i1 %exitcond, label %exit, label %for.body412 413exit:414  %vl.1.lcssa = phi float [ %v1.1, %for.body ]415  store float %vl.1.lcssa, ptr @A416  ret void417}418