158 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2;RUN: opt -passes=newgvn -S < %s | FileCheck %s3target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"4target triple = "x86_64-apple-macosx10.12.0"5;; Ensure we don't infinite loop when all phi arguments are really unreachable or self-defined6define void @fn1(i64 noundef %arg, i1 %arg2) {7; CHECK-LABEL: @fn1(8; CHECK-NEXT: entry:9; CHECK-NEXT: br i1 [[ARG2:%.*]], label [[IF_THEN:%.*]], label [[COND_TRUE:%.*]]10; CHECK: if.then:11; CHECK-NEXT: br i1 false, label [[FIRSTPHIBLOCK:%.*]], label [[TEMP:%.*]]12; CHECK: firstphiblock:13; CHECK-NEXT: br i1 [[ARG2]], label [[FOR_COND17THREAD_PRE_SPLIT:%.*]], label [[SECONDPHIBLOCK:%.*]]14; CHECK: secondphiblock:15; CHECK-NEXT: [[SECONDPHI:%.*]] = phi i64 [ [[THIRDPHI:%.*]], [[THIRDPHIBLOCK:%.*]] ], [ undef, [[FIRSTPHIBLOCK]] ]16; CHECK-NEXT: br i1 [[ARG2]], label [[FIRSTPHIBLOCK]], label [[THIRDPHIBLOCK]]17; CHECK: thirdphiblock:18; CHECK-NEXT: [[THIRDPHI]] = phi i64 [ [[SECONDPHI]], [[SECONDPHIBLOCK]] ], [ [[DIV:%.*]], [[COND_TRUE]] ]19; CHECK-NEXT: br label [[SECONDPHIBLOCK]]20; CHECK: for.cond17thread-pre-split:21; CHECK-NEXT: br label [[COND_TRUE]]22; CHECK: cond.true:23; CHECK-NEXT: [[DIV]] = sdiv i64 [[ARG:%.*]], 424; CHECK-NEXT: br label [[THIRDPHIBLOCK]]25; CHECK: temp:26; CHECK-NEXT: ret void27;28entry:29 br i1 %arg2, label %if.then, label %cond.true30if.then:31 br i1 false, label %firstphiblock, label %temp32firstphiblock:33 %firstphi = phi i64 [ %arg, %if.then ], [ undef, %secondphiblock ]34 br i1 %arg2, label %for.cond17thread-pre-split, label %secondphiblock35secondphiblock:36 %secondphi = phi i64 [ %thirdphi, %thirdphiblock ], [ %firstphi, %firstphiblock ]37 br i1 %arg2, label %firstphiblock, label %thirdphiblock38thirdphiblock:39 %thirdphi = phi i64 [ %secondphi, %secondphiblock ], [ %div, %cond.true ]40 br label %secondphiblock41for.cond17thread-pre-split:42 br label %cond.true43cond.true:44 %fourthphi = phi i64 [ %arg, %entry ], [ %firstphi, %for.cond17thread-pre-split ]45 %div = sdiv i64 %fourthphi, 446 br label %thirdphiblock47temp:48 ret void49}50define void @fn2(i64 noundef %arg, i1 %arg2) {51; CHECK-LABEL: @fn2(52; CHECK-NEXT: entry:53; CHECK-NEXT: br i1 [[ARG2:%.*]], label [[IF_THEN:%.*]], label [[COND_TRUE:%.*]]54; CHECK: if.then:55; CHECK-NEXT: br i1 false, label [[FIRSTPHIBLOCK:%.*]], label [[TEMP:%.*]]56; CHECK: firstphiblock:57; CHECK-NEXT: [[FIRSTPHI:%.*]] = phi i64 [ poison, [[IF_THEN]] ], [ [[SECONDPHI:%.*]], [[SECONDPHIBLOCK:%.*]] ]58; CHECK-NEXT: br i1 [[ARG2]], label [[FOR_COND17THREAD_PRE_SPLIT:%.*]], label [[SECONDPHIBLOCK]]59; CHECK: secondphiblock:60; CHECK-NEXT: [[SECONDPHI]] = phi i64 [ [[THIRDPHI:%.*]], [[THIRDPHIBLOCK:%.*]] ], [ [[FIRSTPHI]], [[FIRSTPHIBLOCK]] ]61; CHECK-NEXT: br i1 [[ARG2]], label [[FIRSTPHIBLOCK]], label [[THIRDPHIBLOCK]]62; CHECK: thirdphiblock:63; CHECK-NEXT: [[THIRDPHI]] = phi i64 [ [[SECONDPHI]], [[SECONDPHIBLOCK]] ], [ [[DIV:%.*]], [[COND_TRUE]] ]64; CHECK-NEXT: br label [[SECONDPHIBLOCK]]65; CHECK: for.cond17thread-pre-split:66; CHECK-NEXT: br label [[COND_TRUE]]67; CHECK: cond.true:68; CHECK-NEXT: [[FOURTHPHI:%.*]] = phi i64 [ [[ARG:%.*]], [[ENTRY:%.*]] ], [ [[FIRSTPHI]], [[FOR_COND17THREAD_PRE_SPLIT]] ]69; CHECK-NEXT: [[DIV]] = sdiv i64 [[FOURTHPHI]], 470; CHECK-NEXT: br label [[THIRDPHIBLOCK]]71; CHECK: temp:72; CHECK-NEXT: ret void73;74entry:75 br i1 %arg2, label %if.then, label %cond.true76if.then:77 br i1 false, label %firstphiblock, label %temp78firstphiblock:79 %firstphi = phi i64 [ %arg, %if.then ], [ %secondphi, %secondphiblock ]80 br i1 %arg2, label %for.cond17thread-pre-split, label %secondphiblock81secondphiblock:82 %secondphi = phi i64 [ %thirdphi, %thirdphiblock ], [ %firstphi, %firstphiblock ]83 br i1 %arg2, label %firstphiblock, label %thirdphiblock84thirdphiblock:85 %thirdphi = phi i64 [ %secondphi, %secondphiblock ], [ %div, %cond.true ]86 br label %secondphiblock87for.cond17thread-pre-split:88 br label %cond.true89cond.true:90 %fourthphi = phi i64 [ %arg, %entry ], [ %firstphi, %for.cond17thread-pre-split ]91 %div = sdiv i64 %fourthphi, 492 br label %thirdphiblock93temp:94 ret void95}96@b = external global i32, align 497@a = external global i32, align 498define void @fn3(i1 %arg, i1 %arg2) {99; CHECK-LABEL: @fn3(100; CHECK-NEXT: entry:101; CHECK-NEXT: br label [[L1:%.*]]102; CHECK: l1.loopexit:103; CHECK-NEXT: br label [[L1]]104; CHECK: l1:105; CHECK-NEXT: [[F_0:%.*]] = phi ptr [ @b, [[ENTRY:%.*]] ], [ @a, [[L1_LOOPEXIT:%.*]] ]106; CHECK-NEXT: br label [[FOR_COND:%.*]]107; CHECK: for.cond.loopexit:108; CHECK-NEXT: store i8 poison, ptr null, align 1109; CHECK-NEXT: br label [[FOR_COND]]110; CHECK: for.cond:111; CHECK-NEXT: br i1 [[ARG:%.*]], label [[FOR_END14:%.*]], label [[FOR_COND1_PREHEADER:%.*]]112; CHECK: for.cond1.preheader:113; CHECK-NEXT: br label [[FOR_BODY3:%.*]]114; CHECK: for.cond1:115; CHECK-NEXT: br label [[L2:%.*]]116; CHECK: for.body3:117; CHECK-NEXT: br i1 [[ARG2:%.*]], label [[FOR_COND1:%.*]], label [[L1_LOOPEXIT]]118; CHECK: l2:119; CHECK-NEXT: [[G_4:%.*]] = phi ptr [ @b, [[FOR_END14]] ], [ @a, [[FOR_COND1]] ]120; CHECK-NEXT: [[F_2:%.*]] = phi ptr [ [[F_0]], [[FOR_END14]] ], [ @a, [[FOR_COND1]] ]121; CHECK-NEXT: br label [[FOR_INC:%.*]]122; CHECK: for.inc:123; CHECK-NEXT: br i1 false, label [[FOR_COND_LOOPEXIT:%.*]], label [[FOR_INC]]124; CHECK: for.end14:125; CHECK-NEXT: br label [[L2]]126;127entry:128 br label %l1129l1.loopexit:130 %g.223.lcssa = phi ptr [ @b, %for.body3 ]131 br label %l1132l1:133 %g.0 = phi ptr [ undef, %entry ], [ %g.223.lcssa, %l1.loopexit ]134 %f.0 = phi ptr [ @b, %entry ], [ @a, %l1.loopexit ]135 br label %for.cond136for.cond.loopexit:137 br label %for.cond138for.cond:139 %g.1 = phi ptr [ %g.0, %l1 ], [ %g.4, %for.cond.loopexit ]140 %f.1 = phi ptr [ %f.0, %l1 ], [ %f.2, %for.cond.loopexit ]141 br i1 %arg, label %for.end14, label %for.cond1.preheader142for.cond1.preheader:143 br label %for.body3144for.cond1:145 br label %l2146for.body3:147 br i1 %arg2, label %for.cond1, label %l1.loopexit148l2:149 %g.4 = phi ptr [ %g.1, %for.end14 ], [ @a, %for.cond1 ]150 %f.2 = phi ptr [ %f.1, %for.end14 ], [ @a, %for.cond1 ]151 br label %for.inc152for.inc:153 br i1 false, label %for.cond.loopexit, label %for.inc154for.end14:155 br label %l2156}157 158