From 37c4aaaf5260973940c580ad9d05f33de416be64 Mon Sep 17 00:00:00 2001 From: Wei Mi Date: Tue, 15 Nov 2016 19:42:05 +0000 Subject: [PATCH] Revert r286999 which caused buildbot test failures. Some testcases need to be made target specific. llvm-svn: 287014 --- llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp | 11 ++-- llvm/test/CodeGen/X86/licm-nested.ll | 2 +- .../Transforms/LoopStrengthReduce/nested-loop.ll | 65 ---------------------- 3 files changed, 7 insertions(+), 71 deletions(-) delete mode 100644 llvm/test/Transforms/LoopStrengthReduce/nested-loop.ll diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp index f22e8a6..7567707 100644 --- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -1048,16 +1048,17 @@ void Cost::RateRegister(const SCEV *Reg, const Loop *L, ScalarEvolution &SE, DominatorTree &DT) { if (const SCEVAddRecExpr *AR = dyn_cast(Reg)) { - // If this is an addrec for another loop, it should be an invariant - // with respect to L since L is the innermost loop (at least - // for now LSR only handles innermost loops). + // If this is an addrec for another loop, don't second-guess its addrec phi + // nodes. LSR isn't currently smart enough to reason about more than one + // loop at a time. LSR has already run on inner loops, will not run on outer + // loops, and cannot be expected to change sibling loops. if (AR->getLoop() != L) { // If the AddRec exists, consider it's register free and leave it alone. if (isExistingPhi(AR, SE)) return; - // Otherwise, it will be an invariant with respect to Loop L. - ++NumRegs; + // Otherwise, do not consider this formula at all. + Lose(); return; } AddRecCost += 1; /// TODO: This should be a function of the stride. diff --git a/llvm/test/CodeGen/X86/licm-nested.ll b/llvm/test/CodeGen/X86/licm-nested.ll index 63e3c5c..42e6d12 100644 --- a/llvm/test/CodeGen/X86/licm-nested.ll +++ b/llvm/test/CodeGen/X86/licm-nested.ll @@ -1,5 +1,5 @@ ; REQUIRES: asserts -; RUN: llc -mtriple=x86_64-apple-darwin -march=x86-64 < %s -o /dev/null -stats -info-output-file - | grep "hoisted out of loops" | grep 5 +; RUN: llc -mtriple=x86_64-apple-darwin -march=x86-64 < %s -o /dev/null -stats -info-output-file - | grep "hoisted out of loops" | grep 4 ; MachineLICM should be able to hoist the symbolic addresses out of ; the inner loops. diff --git a/llvm/test/Transforms/LoopStrengthReduce/nested-loop.ll b/llvm/test/Transforms/LoopStrengthReduce/nested-loop.ll deleted file mode 100644 index b563eb3..0000000 --- a/llvm/test/Transforms/LoopStrengthReduce/nested-loop.ll +++ /dev/null @@ -1,65 +0,0 @@ -; RUN: opt -loop-reduce -S < %s | FileCheck %s -; Check when we use an outerloop induction variable inside of an innerloop -; induction value expr, LSR can still choose to use single induction variable -; for the innerloop and share it in multiple induction value exprs. - -target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" -target triple = "x86_64-unknown-linux-gnu" - -define void @foo(i32 %size, i32 %nsteps, i32 %hsize, i32* %lined, i8* %maxarray) { -entry: - %cmp215 = icmp sgt i32 %size, 1 - %t0 = zext i32 %size to i64 - %t1 = sext i32 %nsteps to i64 - %sub2 = sub i64 %t0, 2 - br label %for.body - -for.body: ; preds = %for.inc, %entry - %indvars.iv2 = phi i64 [ %indvars.iv.next3, %for.inc ], [ 0, %entry ] - %t2 = mul nsw i64 %indvars.iv2, %t0 - br i1 %cmp215, label %for.body2.preheader, label %for.inc - -for.body2.preheader: ; preds = %for.body - br label %for.body2 - -; Check LSR only generates one induction variable for for.body2 and the induction -; variable will be shared by multiple array accesses. -; CHECK: for.body2: -; CHECK-NEXT: [[LSR:%[^,]+]] = phi i64 [ %lsr.iv.next, %for.body2 ], [ 0, %for.body2.preheader ] -; CHECK-NOT: = phi i64 [ {{.*}}, %for.body2 ], [ {{.*}}, %for.body2.preheader ] -; CHECK: [[SCEVGEP1:%[^,]+]] = getelementptr i8, i8* %maxarray, i64 [[LSR]] -; CHECK: [[SCEVGEP2:%[^,]+]] = getelementptr i8, i8* [[SCEVGEP1]], i64 1 -; CHECK: {{.*}} = load i8, i8* [[SCEVGEP2]], align 1 -; CHECK: [[SCEVGEP3:%[^,]+]] = getelementptr i8, i8* {{.*}}, i64 [[LSR]] -; CHECK: {{.*}} = load i8, i8* [[SCEVGEP3]], align 1 -; CHECK: [[SCEVGEP4:%[^,]+]] = getelementptr i8, i8* {{.*}}, i64 [[LSR]] -; CHECK: store i8 {{.*}}, i8* [[SCEVGEP4]], align 1 -; CHECK: br i1 %exitcond, label %for.body2, label %for.inc.loopexit - -for.body2: ; preds = %for.body2.preheader, %for.body2 - %indvars.iv = phi i64 [ 1, %for.body2.preheader ], [ %indvars.iv.next, %for.body2 ] - %arrayidx1 = getelementptr inbounds i8, i8* %maxarray, i64 %indvars.iv - %v1 = load i8, i8* %arrayidx1, align 1 - %idx2 = add nsw i64 %indvars.iv, %sub2 - %arrayidx2 = getelementptr inbounds i8, i8* %maxarray, i64 %idx2 - %v2 = load i8, i8* %arrayidx2, align 1 - %tmpv = xor i8 %v1, %v2 - %t4 = add nsw i64 %t2, %indvars.iv - %add.ptr = getelementptr inbounds i8, i8* %maxarray, i64 %t4 - store i8 %tmpv, i8* %add.ptr, align 1 - %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 - %wide.trip.count = zext i32 %size to i64 - %exitcond = icmp ne i64 %indvars.iv.next, %wide.trip.count - br i1 %exitcond, label %for.body2, label %for.inc.loopexit - -for.inc.loopexit: ; preds = %for.body2 - br label %for.inc - -for.inc: ; preds = %for.inc.loopexit, %for.body - %indvars.iv.next3 = add nuw nsw i64 %indvars.iv2, 1 - %cmp = icmp slt i64 %indvars.iv.next3, %t1 - br i1 %cmp, label %for.body, label %for.end.loopexit - -for.end.loopexit: ; preds = %for.inc - ret void -} -- 2.7.4