130 lines · plain
1; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -hoist-const-stores -ppc-stack-ptr-caller-preserved < %s | FileCheck %s2; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -hoist-const-stores -ppc-stack-ptr-caller-preserved < %s | FileCheck %s -check-prefix=CHECKBE3 4; Test hoist out of single loop5define signext i32 @test1(i32 signext %lim, ptr nocapture %Func) {6entry:7; CHECK-LABEL: test18; CHECK: for.body.preheader9; CHECK: std 2, 24(1)10; CHECK: for.body11; CHECK-NOT: std 2, 24(1)12; CHECKBE-LABEL: test113; CHECKBE: for.body.preheader14; CHECKBE: std 2, 40(1)15; CHECKBE: for.body16; CHECKBE-NOT: std 2, 40(1)17 18 %cmp6 = icmp sgt i32 %lim, 019 br i1 %cmp6, label %for.body.preheader, label %for.cond.cleanup20 21for.body.preheader: ; preds = %entry22 br label %for.body23 24for.cond.cleanup: ; preds = %for.body, %entry25 %Sum.0.lcssa = phi i32 [ 0, %entry ], [ %add, %for.body ]26 ret i32 %Sum.0.lcssa27 28for.body: ; preds = %for.body.preheader, %for.body29 %i.08 = phi i32 [ %inc, %for.body ], [ 0, %for.body.preheader ]30 %Sum.07 = phi i32 [ %add, %for.body ], [ 0, %for.body.preheader ]31 %call = tail call signext i32 %Func(i32 signext %i.08)32 %add = add nsw i32 %call, %Sum.0733 %inc = add nuw nsw i32 %i.08, 134 %exitcond = icmp eq i32 %inc, %lim35 br i1 %exitcond, label %for.cond.cleanup, label %for.body36}37 38; Test hoist of nested loop goes to outter loop preheader39define signext i32 @test2(i32 signext %lim, ptr nocapture %Func) {40entry:41; CHECK-LABEL: test242; CHECK: for.body4.lr.ph.preheader43; CHECK: std 2, 24(1)44; CHECK: for.body4.lr.ph45; CHECK-NOT: std 2, 24(1)46; CHECKBE-LABEL: test247; CHECKBE: for.body4.lr.ph.preheader48; CHECKBE: std 2, 40(1)49; CHECKBE: for.body4.lr.ph50; CHECKBE-NOT: std 2, 40(1)51 52 %cmp20 = icmp sgt i32 %lim, 053 br i1 %cmp20, label %for.body4.lr.ph.preheader, label %for.cond.cleanup54 55for.body4.lr.ph.preheader: ; preds = %entry56 br label %for.body4.lr.ph57 58for.cond.cleanup: ; preds = %for.cond.cleanup3, %entry59 %Sum.0.lcssa = phi i32 [ 0, %entry ], [ %add, %for.cond.cleanup3 ]60 ret i32 %Sum.0.lcssa61 62for.body4.lr.ph: ; preds = %for.body4.lr.ph.preheader, %for.cond.cleanup363 %j.022 = phi i32 [ %inc6, %for.cond.cleanup3 ], [ 0, %for.body4.lr.ph.preheader ]64 %Sum.021 = phi i32 [ %add, %for.cond.cleanup3 ], [ 0, %for.body4.lr.ph.preheader ]65 br label %for.body466 67for.cond.cleanup3: ; preds = %for.body468 %inc6 = add nuw nsw i32 %j.022, 169 %exitcond24 = icmp eq i32 %inc6, %lim70 br i1 %exitcond24, label %for.cond.cleanup, label %for.body4.lr.ph71 72for.body4: ; preds = %for.body4, %for.body4.lr.ph73 %i.019 = phi i32 [ %j.022, %for.body4.lr.ph ], [ %inc, %for.body4 ]74 %Sum.118 = phi i32 [ %Sum.021, %for.body4.lr.ph ], [ %add, %for.body4 ]75 %call = tail call signext i32 %Func(i32 signext %i.019)76 %add = add nsw i32 %call, %Sum.11877 %inc = add nuw nsw i32 %i.019, 178 %exitcond = icmp eq i32 %inc, %lim79 br i1 %exitcond, label %for.cond.cleanup3, label %for.body480}81 82; Test hoist out of if statement with low branch probability83; FIXME: we shouldn't hoist in such cases as it could increase the number84; of stores after hoisting.85define signext i32 @test3(i32 signext %lim, ptr nocapture %Func) {86entry:87; CHECK-LABEL: test388; CHECK: %for.body.lr.ph89; CHECK: std 2, 24(1)90; CHECK: %for.body91; CHECK-NOT: std 2, 24(1)92; CHECKBE-LABEL: test393; CHECKBE: %for.body.lr.ph94; CHECKBE: std 2, 40(1)95; CHECKBE: %for.body96; CHECKBE-NOT: std 2, 40(1)97 98 %cmp13 = icmp sgt i32 %lim, 099 br i1 %cmp13, label %for.body.lr.ph, label %for.cond.cleanup100 101for.body.lr.ph: ; preds = %entry102 %sub = add nsw i32 %lim, -1103 br label %for.body104 105for.cond.cleanup: ; preds = %if.end, %entry106 %Sum.0.lcssa = phi i32 [ 0, %entry ], [ %add3, %if.end ]107 ret i32 %Sum.0.lcssa108 109for.body: ; preds = %if.end, %for.body.lr.ph110 %i.015 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %if.end ]111 %Sum.014 = phi i32 [ 0, %for.body.lr.ph ], [ %add3, %if.end ]112 %cmp1 = icmp eq i32 %i.015, %sub113 br i1 %cmp1, label %if.then, label %if.end114 115if.then: ; preds = %for.body116 %call = tail call signext i32 %Func(i32 signext %sub)117 %add = add nsw i32 %call, %Sum.014118 br label %if.end119 120if.end: ; preds = %if.then, %for.body121 %Sum.1 = phi i32 [ %add, %if.then ], [ %Sum.014, %for.body ]122 %call2 = tail call signext i32 @func(i32 signext %i.015)123 %add3 = add nsw i32 %call2, %Sum.1124 %inc = add nuw nsw i32 %i.015, 1125 %exitcond = icmp eq i32 %inc, %lim126 br i1 %exitcond, label %for.cond.cleanup, label %for.body127}128 129declare signext i32 @func(i32 signext)130