Hi Chandler,<br><br>Looks like this revision added these two failed tests to builder clang-native-arm-cortex-a9:<br><br>LLVM :: Transforms/LoopStrengthReduce/post-inc-icmpzero.ll<br>LLVM :: Transforms/LoopStrengthReduce/2012-07-18-LimitReassociate.ll<br>
<br>Please have a look at this?<br><br>Thanks<br><br>Galina<br><br>r 171734:<br><a href="http://lab.llvm.org:8011/builders/clang-native-arm-cortex-a9/builds/4332">http://lab.llvm.org:8011/builders/clang-native-arm-cortex-a9/builds/4332</a><br>
<br>r 171735:<br><a href="http://lab.llvm.org:8011/builders/clang-native-arm-cortex-a9/builds/4338">http://lab.llvm.org:8011/builders/clang-native-arm-cortex-a9/builds/4338</a><br><br><br><br><br><div class="gmail_quote">
On Mon, Jan 7, 2013 at 6:41 AM, Chandler Carruth <span dir="ltr"><<a href="mailto:chandlerc@gmail.com" target="_blank">chandlerc@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Author: chandlerc<br>
Date: Mon Jan 7 08:41:08 2013<br>
New Revision: 171735<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=171735&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=171735&view=rev</a><br>
Log:<br>
Switch the SCEV expander and LoopStrengthReduce to use<br>
TargetTransformInfo rather than TargetLowering, removing one of the<br>
primary instances of the layering violation of Transforms depending<br>
directly on Target.<br>
<br>
This is a really big deal because LSR used to be a "special" pass that<br>
could only be tested fully using llc and by looking at the full output<br>
of it. It also couldn't run with any other loop passes because it had to<br>
be created by the backend. No longer is this true. LSR is now just<br>
a normal pass and we should probably lift the creation of LSR out of<br>
lib/CodeGen/Passes.cpp and into the PassManagerBuilder. =] I've not done<br>
this, or updated all of the tests to use opt and a triple, because<br>
I suspect someone more familiar with LSR would do a better job. This<br>
change should be essentially without functional impact for normal<br>
compilations, and only change behvaior of targetless compilations.<br>
<br>
The conversion required changing all of the LSR code to refer to the TTI<br>
interfaces, which fortunately are very similar to TargetLowering's<br>
interfaces. However, it also allowed us to *always* expect to have some<br>
implementation around. I've pushed that simplification through the pass,<br>
and leveraged it to simplify code somewhat. It required some test<br>
updates for one of two things: either we used to skip some checks<br>
altogether but now we get the default "no" answer for them, or we used<br>
to have no information about the target and now we do have some.<br>
<br>
I've also started the process of removing AddrMode, as the TTI interface<br>
doesn't use it any longer. In some cases this simplifies code, and in<br>
others it adds some complexity, but I think it's not a bad tradeoff even<br>
there. Subsequent patches will try to clean this up even further and use<br>
other (more appropriate) abstractions.<br>
<br>
Yet again, almost all of the formatting changes brought to you by<br>
clang-format. =]<br>
<br>
Added:<br>
llvm/trunk/test/Transforms/LoopStrengthReduce/X86/2008-08-14-ShadowIV.ll<br>
- copied, changed from r171726, llvm/trunk/test/Transforms/LoopStrengthReduce/2008-08-14-ShadowIV.ll<br>
llvm/trunk/test/Transforms/LoopStrengthReduce/X86/2011-07-20-DoubleIV.ll<br>
- copied, changed from r171726, llvm/trunk/test/Transforms/LoopStrengthReduce/2011-07-20-DoubleIV.ll<br>
Removed:<br>
llvm/trunk/test/Transforms/LoopStrengthReduce/2008-08-14-ShadowIV.ll<br>
llvm/trunk/test/Transforms/LoopStrengthReduce/2011-07-20-DoubleIV.ll<br>
Modified:<br>
llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h<br>
llvm/trunk/include/llvm/Transforms/Scalar.h<br>
llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp<br>
llvm/trunk/lib/Analysis/TargetTransformInfo.cpp<br>
llvm/trunk/lib/CodeGen/Passes.cpp<br>
llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp<br>
llvm/trunk/test/Transforms/LoopStrengthReduce/2012-07-18-LimitReassociate.ll<br>
llvm/trunk/test/Transforms/LoopStrengthReduce/post-inc-icmpzero.ll<br>
<br>
Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h?rev=171735&r1=171734&r2=171735&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h?rev=171735&r1=171734&r2=171735&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h (original)<br>
+++ llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h Mon Jan 7 08:41:08 2013<br>
@@ -22,7 +22,7 @@<br>
#include <set><br>
<br>
namespace llvm {<br>
- class TargetLowering;<br>
+ class TargetTransformInfo;<br>
<br>
/// Return true if the given expression is safe to expand in the sense that<br>
/// all materialized values are safe to speculate.<br>
@@ -129,7 +129,7 @@<br>
/// representative. Return the number of phis eliminated.<br>
unsigned replaceCongruentIVs(Loop *L, const DominatorTree *DT,<br>
SmallVectorImpl<WeakVH> &DeadInsts,<br>
- const TargetLowering *TLI = NULL);<br>
+ const TargetTransformInfo *TTI = NULL);<br>
<br>
/// expandCodeFor - Insert code to directly compute the specified SCEV<br>
/// expression into the program. The inserted code is inserted into the<br>
<br>
Modified: llvm/trunk/include/llvm/Transforms/Scalar.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Scalar.h?rev=171735&r1=171734&r2=171735&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Scalar.h?rev=171735&r1=171734&r2=171735&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/Transforms/Scalar.h (original)<br>
+++ llvm/trunk/include/llvm/Transforms/Scalar.h Mon Jan 7 08:41:08 2013<br>
@@ -115,11 +115,9 @@<br>
//===----------------------------------------------------------------------===//<br>
//<br>
// LoopStrengthReduce - This pass is strength reduces GEP instructions that use<br>
-// a loop's canonical induction variable as one of their indices. It takes an<br>
-// optional parameter used to consult the target machine whether certain<br>
-// transformations are profitable.<br>
+// a loop's canonical induction variable as one of their indices.<br>
//<br>
-Pass *createLoopStrengthReducePass(const TargetLowering *TLI = 0);<br>
+Pass *createLoopStrengthReducePass();<br>
<br>
Pass *createGlobalMergePass(const TargetLowering *TLI = 0);<br>
<br>
<br>
Modified: llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp?rev=171735&r1=171734&r2=171735&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp?rev=171735&r1=171734&r2=171735&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp (original)<br>
+++ llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Mon Jan 7 08:41:08 2013<br>
@@ -16,11 +16,11 @@<br>
#include "llvm/Analysis/ScalarEvolutionExpander.h"<br>
#include "llvm/ADT/STLExtras.h"<br>
#include "llvm/Analysis/LoopInfo.h"<br>
+#include "llvm/Analysis/TargetTransformInfo.h"<br>
#include "llvm/IR/DataLayout.h"<br>
#include "llvm/IR/IntrinsicInst.h"<br>
#include "llvm/IR/LLVMContext.h"<br>
#include "llvm/Support/Debug.h"<br>
-#include "llvm/Target/TargetLowering.h"<br>
<br>
using namespace llvm;<br>
<br>
@@ -1600,14 +1600,14 @@<br>
/// the same context that SCEVExpander is used.<br>
unsigned SCEVExpander::replaceCongruentIVs(Loop *L, const DominatorTree *DT,<br>
SmallVectorImpl<WeakVH> &DeadInsts,<br>
- const TargetLowering *TLI) {<br>
+ const TargetTransformInfo *TTI) {<br>
// Find integer phis in order of increasing width.<br>
SmallVector<PHINode*, 8> Phis;<br>
for (BasicBlock::iterator I = L->getHeader()->begin();<br>
PHINode *Phi = dyn_cast<PHINode>(I); ++I) {<br>
Phis.push_back(Phi);<br>
}<br>
- if (TLI)<br>
+ if (TTI)<br>
std::sort(Phis.begin(), Phis.end(), width_descending);<br>
<br>
unsigned NumElim = 0;<br>
@@ -1635,8 +1635,8 @@<br>
PHINode *&OrigPhiRef = ExprToIVMap[SE.getSCEV(Phi)];<br>
if (!OrigPhiRef) {<br>
OrigPhiRef = Phi;<br>
- if (Phi->getType()->isIntegerTy() && TLI<br>
- && TLI->isTruncateFree(Phi->getType(), Phis.back()->getType())) {<br>
+ if (Phi->getType()->isIntegerTy() && TTI<br>
+ && TTI->isTruncateFree(Phi->getType(), Phis.back()->getType())) {<br>
// This phi can be freely truncated to the narrowest phi type. Map the<br>
// truncated expression to it so it will be reused for narrow types.<br>
const SCEV *TruncExpr =<br>
<br>
Modified: llvm/trunk/lib/Analysis/TargetTransformInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/TargetTransformInfo.cpp?rev=171735&r1=171734&r2=171735&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/TargetTransformInfo.cpp?rev=171735&r1=171734&r2=171735&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Analysis/TargetTransformInfo.cpp (original)<br>
+++ llvm/trunk/lib/Analysis/TargetTransformInfo.cpp Mon Jan 7 08:41:08 2013<br>
@@ -179,7 +179,9 @@<br>
<br>
bool isLegalAddressingMode(Type *Ty, GlobalValue *BaseGV, int64_t BaseOffset,<br>
bool HasBaseReg, int64_t Scale) const {<br>
- return false;<br>
+ // Guess that reg+reg addressing is allowed. This heuristic is taken from<br>
+ // the implementation of LSR.<br>
+ return !BaseGV && BaseOffset == 0 && Scale <= 1;<br>
}<br>
<br>
bool isTruncateFree(Type *Ty1, Type *Ty2) const {<br>
<br>
Modified: llvm/trunk/lib/CodeGen/Passes.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/Passes.cpp?rev=171735&r1=171734&r2=171735&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/Passes.cpp?rev=171735&r1=171734&r2=171735&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/Passes.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/Passes.cpp Mon Jan 7 08:41:08 2013<br>
@@ -362,7 +362,7 @@<br>
<br>
// Run loop strength reduction before anything else.<br>
if (getOptLevel() != CodeGenOpt::None && !DisableLSR) {<br>
- addPass(createLoopStrengthReducePass(getTargetLowering()));<br>
+ addPass(createLoopStrengthReducePass());<br>
if (PrintLSR)<br>
addPass(createPrintFunctionPass("\n\n*** Code after LSR ***\n", &dbgs()));<br>
}<br>
<br>
Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=171735&r1=171734&r2=171735&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=171735&r1=171734&r2=171735&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Mon Jan 7 08:41:08 2013<br>
@@ -37,8 +37,8 @@<br>
//<br>
// TODO: Handle multiple loops at a time.<br>
//<br>
-// TODO: Should TargetLowering::AddrMode::BaseGV be changed to a ConstantExpr<br>
-// instead of a GlobalValue?<br>
+// TODO: Should the addressing mode BaseGV be changed to a ConstantExpr instead<br>
+// of a GlobalValue?<br>
//<br>
// TODO: When truncation is free, truncate ICmp users' operands to make it a<br>
// smaller encoding (on x86 at least).<br>
@@ -63,6 +63,7 @@<br>
#include "llvm/Analysis/IVUsers.h"<br>
#include "llvm/Analysis/LoopPass.h"<br>
#include "llvm/Analysis/ScalarEvolutionExpander.h"<br>
+#include "llvm/Analysis/TargetTransformInfo.h"<br>
#include "llvm/Assembly/Writer.h"<br>
#include "llvm/IR/Constants.h"<br>
#include "llvm/IR/DerivedTypes.h"<br>
@@ -72,7 +73,6 @@<br>
#include "llvm/Support/Debug.h"<br>
#include "llvm/Support/ValueHandle.h"<br>
#include "llvm/Support/raw_ostream.h"<br>
-#include "llvm/Target/TargetLowering.h"<br>
#include "llvm/Transforms/Utils/BasicBlockUtils.h"<br>
#include "llvm/Transforms/Utils/Local.h"<br>
#include <algorithm><br>
@@ -1270,46 +1270,42 @@<br>
/// isLegalUse - Test whether the use described by AM is "legal", meaning it can<br>
/// be completely folded into the user instruction at isel time. This includes<br>
/// address-mode folding and special icmp tricks.<br>
-static bool isLegalUse(const AddrMode &AM,<br>
- LSRUse::KindType Kind, Type *AccessTy,<br>
- const TargetLowering *TLI) {<br>
+static bool isLegalUse(const TargetTransformInfo &TTI, LSRUse::KindType Kind,<br>
+ Type *AccessTy, GlobalValue *BaseGV, int64_t BaseOffset,<br>
+ bool HasBaseReg, int64_t Scale) {<br>
switch (Kind) {<br>
case LSRUse::Address:<br>
- // If we have low-level target information, ask the target if it can<br>
- // completely fold this address.<br>
- if (TLI) return TLI->isLegalAddressingMode(AM, AccessTy);<br>
+ return TTI.isLegalAddressingMode(AccessTy, BaseGV, BaseOffset, HasBaseReg, Scale);<br>
<br>
// Otherwise, just guess that reg+reg addressing is legal.<br>
- return !AM.BaseGV && AM.BaseOffs == 0 && AM.Scale <= 1;<br>
+ //return ;<br>
<br>
case LSRUse::ICmpZero:<br>
// There's not even a target hook for querying whether it would be legal to<br>
// fold a GV into an ICmp.<br>
- if (AM.BaseGV)<br>
+ if (BaseGV)<br>
return false;<br>
<br>
// ICmp only has two operands; don't allow more than two non-trivial parts.<br>
- if (AM.Scale != 0 && AM.HasBaseReg && AM.BaseOffs != 0)<br>
+ if (Scale != 0 && HasBaseReg && BaseOffset != 0)<br>
return false;<br>
<br>
// ICmp only supports no scale or a -1 scale, as we can "fold" a -1 scale by<br>
// putting the scaled register in the other operand of the icmp.<br>
- if (AM.Scale != 0 && AM.Scale != -1)<br>
+ if (Scale != 0 && Scale != -1)<br>
return false;<br>
<br>
// If we have low-level target information, ask the target if it can fold an<br>
// integer immediate on an icmp.<br>
- if (AM.BaseOffs != 0) {<br>
- if (!TLI)<br>
- return false;<br>
+ if (BaseOffset != 0) {<br>
// We have one of:<br>
- // ICmpZero BaseReg + Offset => ICmp BaseReg, -Offset<br>
- // ICmpZero -1*ScaleReg + Offset => ICmp ScaleReg, Offset<br>
+ // ICmpZero BaseReg + BaseOffset => ICmp BaseReg, -BaseOffset<br>
+ // ICmpZero -1*ScaleReg + BaseOffset => ICmp ScaleReg, BaseOffset<br>
// Offs is the ICmp immediate.<br>
- int64_t Offs = AM.BaseOffs;<br>
- if (AM.Scale == 0)<br>
- Offs = -(uint64_t)Offs; // The cast does the right thing with INT64_MIN.<br>
- return TLI->isLegalICmpImmediate(Offs);<br>
+ if (Scale == 0)<br>
+ // The cast does the right thing with INT64_MIN.<br>
+ BaseOffset = -(uint64_t)BaseOffset;<br>
+ return TTI.isLegalICmpImmediate(BaseOffset);<br>
}<br>
<br>
// ICmpZero BaseReg + -1*ScaleReg => ICmp BaseReg, ScaleReg<br>
@@ -1317,92 +1313,87 @@<br>
<br>
case LSRUse::Basic:<br>
// Only handle single-register values.<br>
- return !AM.BaseGV && AM.Scale == 0 && AM.BaseOffs == 0;<br>
+ return !BaseGV && Scale == 0 && BaseOffset == 0;<br>
<br>
case LSRUse::Special:<br>
// Special case Basic to handle -1 scales.<br>
- return !AM.BaseGV && (AM.Scale == 0 || AM.Scale == -1) && AM.BaseOffs == 0;<br>
+ return !BaseGV && (Scale == 0 || Scale == -1) && BaseOffset == 0;<br>
}<br>
<br>
llvm_unreachable("Invalid LSRUse Kind!");<br>
}<br>
<br>
-static bool isLegalUse(AddrMode AM,<br>
- int64_t MinOffset, int64_t MaxOffset,<br>
- LSRUse::KindType Kind, Type *AccessTy,<br>
- const TargetLowering *TLI) {<br>
+static bool isLegalUse(const TargetTransformInfo &TTI, int64_t MinOffset,<br>
+ int64_t MaxOffset, LSRUse::KindType Kind, Type *AccessTy,<br>
+ GlobalValue *BaseGV, int64_t BaseOffset, bool HasBaseReg,<br>
+ int64_t Scale) {<br>
// Check for overflow.<br>
- if (((int64_t)((uint64_t)AM.BaseOffs + MinOffset) > AM.BaseOffs) !=<br>
+ if (((int64_t)((uint64_t)BaseOffset + MinOffset) > BaseOffset) !=<br>
(MinOffset > 0))<br>
return false;<br>
- AM.BaseOffs = (uint64_t)AM.BaseOffs + MinOffset;<br>
- if (isLegalUse(AM, Kind, AccessTy, TLI)) {<br>
- AM.BaseOffs = (uint64_t)AM.BaseOffs - MinOffset;<br>
- // Check for overflow.<br>
- if (((int64_t)((uint64_t)AM.BaseOffs + MaxOffset) > AM.BaseOffs) !=<br>
- (MaxOffset > 0))<br>
- return false;<br>
- AM.BaseOffs = (uint64_t)AM.BaseOffs + MaxOffset;<br>
- return isLegalUse(AM, Kind, AccessTy, TLI);<br>
- }<br>
- return false;<br>
+ MinOffset = (uint64_t)BaseOffset + MinOffset;<br>
+ if (((int64_t)((uint64_t)BaseOffset + MaxOffset) > BaseOffset) !=<br>
+ (MaxOffset > 0))<br>
+ return false;<br>
+ MaxOffset = (uint64_t)BaseOffset + MaxOffset;<br>
+<br>
+ return isLegalUse(TTI, Kind, AccessTy, BaseGV, MinOffset, HasBaseReg,<br>
+ Scale) &&<br>
+ isLegalUse(TTI, Kind, AccessTy, BaseGV, MaxOffset, HasBaseReg, Scale);<br>
}<br>
<br>
-static bool isAlwaysFoldable(int64_t BaseOffs,<br>
- GlobalValue *BaseGV,<br>
- bool HasBaseReg,<br>
+static bool isLegalUse(const TargetTransformInfo &TTI, int64_t MinOffset,<br>
+ int64_t MaxOffset, LSRUse::KindType Kind, Type *AccessTy,<br>
+ const Formula &F) {<br>
+ return isLegalUse(TTI, MinOffset, MaxOffset, Kind, AccessTy, F.AM.BaseGV,<br>
+ F.AM.BaseOffs, F.AM.HasBaseReg, F.AM.Scale);<br>
+}<br>
+<br>
+static bool isAlwaysFoldable(const TargetTransformInfo &TTI,<br>
LSRUse::KindType Kind, Type *AccessTy,<br>
- const TargetLowering *TLI) {<br>
+ GlobalValue *BaseGV, int64_t BaseOffset,<br>
+ bool HasBaseReg) {<br>
// Fast-path: zero is always foldable.<br>
- if (BaseOffs == 0 && !BaseGV) return true;<br>
+ if (BaseOffset == 0 && !BaseGV) return true;<br>
<br>
// Conservatively, create an address with an immediate and a<br>
// base and a scale.<br>
- AddrMode AM;<br>
- AM.BaseOffs = BaseOffs;<br>
- AM.BaseGV = BaseGV;<br>
- AM.HasBaseReg = HasBaseReg;<br>
- AM.Scale = Kind == LSRUse::ICmpZero ? -1 : 1;<br>
+ int64_t Scale = Kind == LSRUse::ICmpZero ? -1 : 1;<br>
<br>
// Canonicalize a scale of 1 to a base register if the formula doesn't<br>
// already have a base register.<br>
- if (!AM.HasBaseReg && AM.Scale == 1) {<br>
- AM.Scale = 0;<br>
- AM.HasBaseReg = true;<br>
+ if (!HasBaseReg && Scale == 1) {<br>
+ Scale = 0;<br>
+ HasBaseReg = true;<br>
}<br>
<br>
- return isLegalUse(AM, Kind, AccessTy, TLI);<br>
+ return isLegalUse(TTI, Kind, AccessTy, BaseGV, BaseOffset, HasBaseReg, Scale);<br>
}<br>
<br>
-static bool isAlwaysFoldable(const SCEV *S,<br>
- int64_t MinOffset, int64_t MaxOffset,<br>
- bool HasBaseReg,<br>
- LSRUse::KindType Kind, Type *AccessTy,<br>
- const TargetLowering *TLI,<br>
- ScalarEvolution &SE) {<br>
+static bool isAlwaysFoldable(const TargetTransformInfo &TTI,<br>
+ ScalarEvolution &SE, int64_t MinOffset,<br>
+ int64_t MaxOffset, LSRUse::KindType Kind,<br>
+ Type *AccessTy, const SCEV *S, bool HasBaseReg) {<br>
// Fast-path: zero is always foldable.<br>
if (S->isZero()) return true;<br>
<br>
// Conservatively, create an address with an immediate and a<br>
// base and a scale.<br>
- int64_t BaseOffs = ExtractImmediate(S, SE);<br>
+ int64_t BaseOffset = ExtractImmediate(S, SE);<br>
GlobalValue *BaseGV = ExtractSymbol(S, SE);<br>
<br>
// If there's anything else involved, it's not foldable.<br>
if (!S->isZero()) return false;<br>
<br>
// Fast-path: zero is always foldable.<br>
- if (BaseOffs == 0 && !BaseGV) return true;<br>
+ if (BaseOffset == 0 && !BaseGV) return true;<br>
<br>
// Conservatively, create an address with an immediate and a<br>
// base and a scale.<br>
- AddrMode AM;<br>
- AM.BaseOffs = BaseOffs;<br>
- AM.BaseGV = BaseGV;<br>
- AM.HasBaseReg = HasBaseReg;<br>
- AM.Scale = Kind == LSRUse::ICmpZero ? -1 : 1;<br>
+ int64_t Scale = Kind == LSRUse::ICmpZero ? -1 : 1;<br>
<br>
- return isLegalUse(AM, MinOffset, MaxOffset, Kind, AccessTy, TLI);<br>
+ return isLegalUse(TTI, MinOffset, MaxOffset, Kind, AccessTy, BaseGV,<br>
+ BaseOffset, HasBaseReg, Scale);<br>
}<br>
<br>
namespace {<br>
@@ -1502,7 +1493,7 @@<br>
ScalarEvolution &SE;<br>
DominatorTree &DT;<br>
LoopInfo &LI;<br>
- const TargetLowering *const TLI;<br>
+ const TargetTransformInfo &TTI;<br>
Loop *const L;<br>
bool Changed;<br>
<br>
@@ -1638,7 +1629,7 @@<br>
Pass *P);<br>
<br>
public:<br>
- LSRInstance(const TargetLowering *tli, Loop *l, Pass *P);<br>
+ LSRInstance(Loop *L, Pass *P);<br>
<br>
bool getChanged() const { return Changed; }<br>
<br>
@@ -1688,12 +1679,9 @@<br>
}<br>
if (!DestTy) continue;<br>
<br>
- if (TLI) {<br>
- // If target does not support DestTy natively then do not apply<br>
- // this transformation.<br>
- EVT DVT = TLI->getValueType(DestTy);<br>
- if (!TLI->isTypeLegal(DVT)) continue;<br>
- }<br>
+ // If target does not support DestTy natively then do not apply<br>
+ // this transformation.<br>
+ if (!TTI.isTypeLegal(DestTy)) continue;<br>
<br>
PHINode *PH = dyn_cast<PHINode>(ShadowUse->getOperand(0));<br>
if (!PH) continue;<br>
@@ -2015,18 +2003,17 @@<br>
if (C->getValue().getMinSignedBits() >= 64 ||<br>
C->getValue().isMinSignedValue())<br>
goto decline_post_inc;<br>
- // Without TLI, assume that any stride might be valid, and so any<br>
- // use might be shared.<br>
- if (!TLI)<br>
- goto decline_post_inc;<br>
// Check for possible scaled-address reuse.<br>
Type *AccessTy = getAccessType(UI->getUser());<br>
- AddrMode AM;<br>
- AM.Scale = C->getSExtValue();<br>
- if (TLI->isLegalAddressingMode(AM, AccessTy))<br>
+ int64_t Scale = C->getSExtValue();<br>
+ if (TTI.isLegalAddressingMode(AccessTy, /*BaseGV=*/ 0,<br>
+ /*BaseOffset=*/ 0,<br>
+ /*HasBaseReg=*/ false, Scale))<br>
goto decline_post_inc;<br>
- AM.Scale = -AM.Scale;<br>
- if (TLI->isLegalAddressingMode(AM, AccessTy))<br>
+ Scale = -Scale;<br>
+ if (TTI.isLegalAddressingMode(AccessTy, /*BaseGV=*/ 0,<br>
+ /*BaseOffset=*/ 0,<br>
+ /*HasBaseReg=*/ false, Scale))<br>
goto decline_post_inc;<br>
}<br>
}<br>
@@ -2096,13 +2083,13 @@<br>
return false;<br>
// Conservatively assume HasBaseReg is true for now.<br>
if (NewOffset < LU.MinOffset) {<br>
- if (!isAlwaysFoldable(LU.MaxOffset - NewOffset, 0, HasBaseReg,<br>
- Kind, AccessTy, TLI))<br>
+ if (!isAlwaysFoldable(TTI, Kind, AccessTy, /*BaseGV=*/ 0,<br>
+ LU.MaxOffset - NewOffset, HasBaseReg))<br>
return false;<br>
NewMinOffset = NewOffset;<br>
} else if (NewOffset > LU.MaxOffset) {<br>
- if (!isAlwaysFoldable(NewOffset - LU.MinOffset, 0, HasBaseReg,<br>
- Kind, AccessTy, TLI))<br>
+ if (!isAlwaysFoldable(TTI, Kind, AccessTy, /*BaseGV=*/ 0,<br>
+ NewOffset - LU.MinOffset, HasBaseReg))<br>
return false;<br>
NewMaxOffset = NewOffset;<br>
}<br>
@@ -2131,7 +2118,8 @@<br>
int64_t Offset = ExtractImmediate(Expr, SE);<br>
<br>
// Basic uses can't accept any offset, for example.<br>
- if (!isAlwaysFoldable(Offset, 0, /*HasBaseReg=*/true, Kind, AccessTy, TLI)) {<br>
+ if (!isAlwaysFoldable(TTI, Kind, AccessTy, /*BaseGV=*/ 0,<br>
+ Offset, /*HasBaseReg=*/ true)) {<br>
Expr = Copy;<br>
Offset = 0;<br>
}<br>
@@ -2396,7 +2384,7 @@<br>
/// TODO: Consider IVInc free if it's already used in another chains.<br>
static bool<br>
isProfitableChain(IVChain &Chain, SmallPtrSet<Instruction*, 4> &Users,<br>
- ScalarEvolution &SE, const TargetLowering *TLI) {<br>
+ ScalarEvolution &SE, const TargetTransformInfo &TTI) {<br>
if (StressIVChain)<br>
return true;<br>
<br>
@@ -2654,7 +2642,7 @@<br>
for (unsigned UsersIdx = 0, NChains = IVChainVec.size();<br>
UsersIdx < NChains; ++UsersIdx) {<br>
if (!isProfitableChain(IVChainVec[UsersIdx],<br>
- ChainUsersVec[UsersIdx].FarUsers, SE, TLI))<br>
+ ChainUsersVec[UsersIdx].FarUsers, SE, TTI))<br>
continue;<br>
// Preserve the chain at UsesIdx.<br>
if (ChainIdx != UsersIdx)<br>
@@ -2681,7 +2669,7 @@<br>
<br>
/// Return true if the IVInc can be folded into an addressing mode.<br>
static bool canFoldIVIncExpr(const SCEV *IncExpr, Instruction *UserInst,<br>
- Value *Operand, const TargetLowering *TLI) {<br>
+ Value *Operand, const TargetTransformInfo &TTI) {<br>
const SCEVConstant *IncConst = dyn_cast<SCEVConstant>(IncExpr);<br>
if (!IncConst || !isAddressUse(UserInst, Operand))<br>
return false;<br>
@@ -2690,8 +2678,9 @@<br>
return false;<br>
<br>
int64_t IncOffset = IncConst->getValue()->getSExtValue();<br>
- if (!isAlwaysFoldable(IncOffset, /*BaseGV=*/0, /*HaseBaseReg=*/false,<br>
- LSRUse::Address, getAccessType(UserInst), TLI))<br>
+ if (!isAlwaysFoldable(TTI, LSRUse::Address,<br>
+ getAccessType(UserInst), /*BaseGV=*/ 0,<br>
+ IncOffset, /*HaseBaseReg=*/ false))<br>
return false;<br>
<br>
return true;<br>
@@ -2762,7 +2751,7 @@<br>
<br>
// If an IV increment can't be folded, use it as the next IV value.<br>
if (!canFoldIVIncExpr(LeftOverExpr, IncI->UserInst, IncI->IVOperand,<br>
- TLI)) {<br>
+ TTI)) {<br>
assert(IVTy == IVOper->getType() && "inconsistent IV increment type");<br>
IVSrc = IVOper;<br>
LeftOverExpr = 0;<br>
@@ -3106,9 +3095,8 @@<br>
<br>
// Don't pull a constant into a register if the constant could be folded<br>
// into an immediate field.<br>
- if (isAlwaysFoldable(*J, LU.MinOffset, LU.MaxOffset,<br>
- Base.getNumRegs() > 1,<br>
- LU.Kind, LU.AccessTy, TLI, SE))<br>
+ if (isAlwaysFoldable(TTI, SE, LU.MinOffset, LU.MaxOffset, LU.Kind,<br>
+ LU.AccessTy, *J, Base.getNumRegs() > 1))<br>
continue;<br>
<br>
// Collect all operands except *J.<br>
@@ -3120,9 +3108,8 @@<br>
// Don't leave just a constant behind in a register if the constant could<br>
// be folded into an immediate field.<br>
if (InnerAddOps.size() == 1 &&<br>
- isAlwaysFoldable(InnerAddOps[0], LU.MinOffset, LU.MaxOffset,<br>
- Base.getNumRegs() > 1,<br>
- LU.Kind, LU.AccessTy, TLI, SE))<br>
+ isAlwaysFoldable(TTI, SE, LU.MinOffset, LU.MaxOffset, LU.Kind,<br>
+ LU.AccessTy, InnerAddOps[0], Base.getNumRegs() > 1))<br>
continue;<br>
<br>
const SCEV *InnerSum = SE.getAddExpr(InnerAddOps);<br>
@@ -3132,10 +3119,10 @@<br>
<br>
// Add the remaining pieces of the add back into the new formula.<br>
const SCEVConstant *InnerSumSC = dyn_cast<SCEVConstant>(InnerSum);<br>
- if (TLI && InnerSumSC &&<br>
+ if (InnerSumSC &&<br>
SE.getTypeSizeInBits(InnerSumSC->getType()) <= 64 &&<br>
- TLI->isLegalAddImmediate((uint64_t)F.UnfoldedOffset +<br>
- InnerSumSC->getValue()->getZExtValue())) {<br>
+ TTI.isLegalAddImmediate((uint64_t)F.UnfoldedOffset +<br>
+ InnerSumSC->getValue()->getZExtValue())) {<br>
F.UnfoldedOffset = (uint64_t)F.UnfoldedOffset +<br>
InnerSumSC->getValue()->getZExtValue();<br>
F.BaseRegs.erase(F.BaseRegs.begin() + i);<br>
@@ -3144,9 +3131,9 @@<br>
<br>
// Add J as its own register, or an unfolded immediate.<br>
const SCEVConstant *SC = dyn_cast<SCEVConstant>(*J);<br>
- if (TLI && SC && SE.getTypeSizeInBits(SC->getType()) <= 64 &&<br>
- TLI->isLegalAddImmediate((uint64_t)F.UnfoldedOffset +<br>
- SC->getValue()->getZExtValue()))<br>
+ if (SC && SE.getTypeSizeInBits(SC->getType()) <= 64 &&<br>
+ TTI.isLegalAddImmediate((uint64_t)F.UnfoldedOffset +<br>
+ SC->getValue()->getZExtValue()))<br>
F.UnfoldedOffset = (uint64_t)F.UnfoldedOffset +<br>
SC->getValue()->getZExtValue();<br>
else<br>
@@ -3204,8 +3191,7 @@<br>
continue;<br>
Formula F = Base;<br>
F.AM.BaseGV = GV;<br>
- if (!isLegalUse(<a href="http://F.AM" target="_blank">F.AM</a>, LU.MinOffset, LU.MaxOffset,<br>
- LU.Kind, LU.AccessTy, TLI))<br>
+ if (!isLegalUse(TTI, LU.MinOffset, LU.MaxOffset, LU.Kind, LU.AccessTy, F))<br>
continue;<br>
F.BaseRegs[i] = G;<br>
(void)InsertFormula(LU, LUIdx, F);<br>
@@ -3229,8 +3215,8 @@<br>
E = Worklist.end(); I != E; ++I) {<br>
Formula F = Base;<br>
F.AM.BaseOffs = (uint64_t)Base.AM.BaseOffs - *I;<br>
- if (isLegalUse(<a href="http://F.AM" target="_blank">F.AM</a>, LU.MinOffset - *I, LU.MaxOffset - *I,<br>
- LU.Kind, LU.AccessTy, TLI)) {<br>
+ if (isLegalUse(TTI, LU.MinOffset - *I, LU.MaxOffset - *I, LU.Kind,<br>
+ LU.AccessTy, F)) {<br>
// Add the offset to the base register.<br>
const SCEV *NewG = SE.getAddExpr(SE.getConstant(G->getType(), *I), G);<br>
// If it cancelled out, drop the base register, otherwise update it.<br>
@@ -3249,8 +3235,7 @@<br>
continue;<br>
Formula F = Base;<br>
F.AM.BaseOffs = (uint64_t)F.AM.BaseOffs + Imm;<br>
- if (!isLegalUse(<a href="http://F.AM" target="_blank">F.AM</a>, LU.MinOffset, LU.MaxOffset,<br>
- LU.Kind, LU.AccessTy, TLI))<br>
+ if (!isLegalUse(TTI, LU.MinOffset, LU.MaxOffset, LU.Kind, LU.AccessTy, F))<br>
continue;<br>
F.BaseRegs[i] = G;<br>
(void)InsertFormula(LU, LUIdx, F);<br>
@@ -3297,7 +3282,7 @@<br>
F.AM.BaseOffs = NewBaseOffs;<br>
<br>
// Check that this scale is legal.<br>
- if (!isLegalUse(<a href="http://F.AM" target="_blank">F.AM</a>, Offset, Offset, LU.Kind, LU.AccessTy, TLI))<br>
+ if (!isLegalUse(TTI, Offset, Offset, LU.Kind, LU.AccessTy, F))<br>
continue;<br>
<br>
// Compensate for the use having MinOffset built into it.<br>
@@ -3352,13 +3337,13 @@<br>
Base.AM.Scale = Factor;<br>
Base.AM.HasBaseReg = Base.BaseRegs.size() > 1;<br>
// Check whether this scale is going to be legal.<br>
- if (!isLegalUse(Base.AM, LU.MinOffset, LU.MaxOffset,<br>
- LU.Kind, LU.AccessTy, TLI)) {<br>
+ if (!isLegalUse(TTI, LU.MinOffset, LU.MaxOffset, LU.Kind, LU.AccessTy,<br>
+ Base)) {<br>
// As a special-case, handle special out-of-loop Basic users specially.<br>
// TODO: Reconsider this special case.<br>
if (LU.Kind == LSRUse::Basic &&<br>
- isLegalUse(Base.AM, LU.MinOffset, LU.MaxOffset,<br>
- LSRUse::Special, LU.AccessTy, TLI) &&<br>
+ isLegalUse(TTI, LU.MinOffset, LU.MaxOffset, LSRUse::Special,<br>
+ LU.AccessTy, Base) &&<br>
LU.AllFixupsOutsideLoop)<br>
LU.Kind = LSRUse::Special;<br>
else<br>
@@ -3391,9 +3376,6 @@<br>
<br>
/// GenerateTruncates - Generate reuse formulae from different IV types.<br>
void LSRInstance::GenerateTruncates(LSRUse &LU, unsigned LUIdx, Formula Base) {<br>
- // This requires TargetLowering to tell us which truncates are free.<br>
- if (!TLI) return;<br>
-<br>
// Don't bother truncating symbolic values.<br>
if (Base.AM.BaseGV) return;<br>
<br>
@@ -3405,7 +3387,7 @@<br>
for (SmallSetVector<Type *, 4>::const_iterator<br>
I = Types.begin(), E = Types.end(); I != E; ++I) {<br>
Type *SrcTy = *I;<br>
- if (SrcTy != DstTy && TLI->isTruncateFree(SrcTy, DstTy)) {<br>
+ if (SrcTy != DstTy && TTI.isTruncateFree(SrcTy, DstTy)) {<br>
Formula F = Base;<br>
<br>
if (F.ScaledReg) F.ScaledReg = SE.getAnyExtendExpr(F.ScaledReg, *I);<br>
@@ -3560,8 +3542,8 @@<br>
continue;<br>
Formula NewF = F;<br>
NewF.AM.BaseOffs = Offs;<br>
- if (!isLegalUse(NewF.AM, LU.MinOffset, LU.MaxOffset,<br>
- LU.Kind, LU.AccessTy, TLI))<br>
+ if (!isLegalUse(TTI, LU.MinOffset, LU.MaxOffset, LU.Kind, LU.AccessTy,<br>
+ NewF))<br>
continue;<br>
NewF.ScaledReg = SE.getAddExpr(NegImmS, NewF.ScaledReg);<br>
<br>
@@ -3585,10 +3567,9 @@<br>
continue;<br>
Formula NewF = F;<br>
NewF.AM.BaseOffs = (uint64_t)NewF.AM.BaseOffs + Imm;<br>
- if (!isLegalUse(NewF.AM, LU.MinOffset, LU.MaxOffset,<br>
- LU.Kind, LU.AccessTy, TLI)) {<br>
- if (!TLI ||<br>
- !TLI->isLegalAddImmediate((uint64_t)NewF.UnfoldedOffset + Imm))<br>
+ if (!isLegalUse(TTI, LU.MinOffset, LU.MaxOffset,<br>
+ LU.Kind, LU.AccessTy, NewF)) {<br>
+ if (!TTI.isLegalAddImmediate((uint64_t)NewF.UnfoldedOffset + Imm))<br>
continue;<br>
NewF = F;<br>
NewF.UnfoldedOffset = (uint64_t)NewF.UnfoldedOffset + Imm;<br>
@@ -3898,9 +3879,8 @@<br>
bool Any = false;<br>
for (size_t i = 0, e = LUThatHas->Formulae.size(); i != e; ++i) {<br>
Formula &F = LUThatHas->Formulae[i];<br>
- if (!isLegalUse(<a href="http://F.AM" target="_blank">F.AM</a>,<br>
- LUThatHas->MinOffset, LUThatHas->MaxOffset,<br>
- LUThatHas->Kind, LUThatHas->AccessTy, TLI)) {<br>
+ if (!isLegalUse(TTI, LUThatHas->MinOffset, LUThatHas->MaxOffset,<br>
+ LUThatHas->Kind, LUThatHas->AccessTy, F)) {<br>
DEBUG(dbgs() << " Deleting "; F.print(dbgs());<br>
dbgs() << '\n');<br>
LUThatHas->DeleteFormula(F);<br>
@@ -4589,13 +4569,11 @@<br>
Changed |= DeleteTriviallyDeadInstructions(DeadInsts);<br>
}<br>
<br>
-LSRInstance::LSRInstance(const TargetLowering *tli, Loop *l, Pass *P)<br>
- : IU(P->getAnalysis<IVUsers>()),<br>
- SE(P->getAnalysis<ScalarEvolution>()),<br>
- DT(P->getAnalysis<DominatorTree>()),<br>
- LI(P->getAnalysis<LoopInfo>()),<br>
- TLI(tli), L(l), Changed(false), IVIncInsertPos(0) {<br>
-<br>
+LSRInstance::LSRInstance(Loop *L, Pass *P)<br>
+ : IU(P->getAnalysis<IVUsers>()), SE(P->getAnalysis<ScalarEvolution>()),<br>
+ DT(P->getAnalysis<DominatorTree>()), LI(P->getAnalysis<LoopInfo>()),<br>
+ TTI(P->getAnalysis<TargetTransformInfo>()), L(L), Changed(false),<br>
+ IVIncInsertPos(0) {<br>
// If LoopSimplify form is not available, stay out of trouble.<br>
if (!L->isLoopSimplifyForm())<br>
return;<br>
@@ -4678,14 +4656,14 @@<br>
<br>
#ifndef NDEBUG<br>
// Formulae should be legal.<br>
- for (SmallVectorImpl<LSRUse>::const_iterator I = Uses.begin(),<br>
- E = Uses.end(); I != E; ++I) {<br>
- const LSRUse &LU = *I;<br>
- for (SmallVectorImpl<Formula>::const_iterator J = LU.Formulae.begin(),<br>
- JE = LU.Formulae.end(); J != JE; ++J)<br>
- assert(isLegalUse(J->AM, LU.MinOffset, LU.MaxOffset,<br>
- LU.Kind, LU.AccessTy, TLI) &&<br>
- "Illegal formula generated!");<br>
+ for (SmallVectorImpl<LSRUse>::const_iterator I = Uses.begin(), E = Uses.end();<br>
+ I != E; ++I) {<br>
+ const LSRUse &LU = *I;<br>
+ for (SmallVectorImpl<Formula>::const_iterator J = LU.Formulae.begin(),<br>
+ JE = LU.Formulae.end();<br>
+ J != JE; ++J)<br>
+ assert(isLegalUse(TTI, LU.MinOffset, LU.MaxOffset, LU.Kind, LU.AccessTy,<br>
+ *J) && "Illegal formula generated!");<br>
};<br>
#endif<br>
<br>
@@ -4757,13 +4735,9 @@<br>
namespace {<br>
<br>
class LoopStrengthReduce : public LoopPass {<br>
- /// TLI - Keep a pointer of a TargetLowering to consult for determining<br>
- /// transformation profitability.<br>
- const TargetLowering *const TLI;<br>
-<br>
public:<br>
static char ID; // Pass ID, replacement for typeid<br>
- explicit LoopStrengthReduce(const TargetLowering *tli = 0);<br>
+ LoopStrengthReduce();<br>
<br>
private:<br>
bool runOnLoop(Loop *L, LPPassManager &LPM);<br>
@@ -4775,6 +4749,7 @@<br>
char LoopStrengthReduce::ID = 0;<br>
INITIALIZE_PASS_BEGIN(LoopStrengthReduce, "loop-reduce",<br>
"Loop Strength Reduction", false, false)<br>
+INITIALIZE_AG_DEPENDENCY(TargetTransformInfo)<br>
INITIALIZE_PASS_DEPENDENCY(DominatorTree)<br>
INITIALIZE_PASS_DEPENDENCY(ScalarEvolution)<br>
INITIALIZE_PASS_DEPENDENCY(IVUsers)<br>
@@ -4784,14 +4759,13 @@<br>
"Loop Strength Reduction", false, false)<br>
<br>
<br>
-Pass *llvm::createLoopStrengthReducePass(const TargetLowering *TLI) {<br>
- return new LoopStrengthReduce(TLI);<br>
+Pass *llvm::createLoopStrengthReducePass() {<br>
+ return new LoopStrengthReduce();<br>
}<br>
<br>
-LoopStrengthReduce::LoopStrengthReduce(const TargetLowering *tli)<br>
- : LoopPass(ID), TLI(tli) {<br>
- initializeLoopStrengthReducePass(*PassRegistry::getPassRegistry());<br>
- }<br>
+LoopStrengthReduce::LoopStrengthReduce() : LoopPass(ID) {<br>
+ initializeLoopStrengthReducePass(*PassRegistry::getPassRegistry());<br>
+}<br>
<br>
void LoopStrengthReduce::getAnalysisUsage(AnalysisUsage &AU) const {<br>
// We split critical edges, so we change the CFG. However, we do update<br>
@@ -4810,13 +4784,14 @@<br>
AU.addRequiredID(LoopSimplifyID);<br>
AU.addRequired<IVUsers>();<br>
AU.addPreserved<IVUsers>();<br>
+ AU.addRequired<TargetTransformInfo>();<br>
}<br>
<br>
bool LoopStrengthReduce::runOnLoop(Loop *L, LPPassManager & /*LPM*/) {<br>
bool Changed = false;<br>
<br>
// Run the main LSR transformation.<br>
- Changed |= LSRInstance(TLI, L, this).getChanged();<br>
+ Changed |= LSRInstance(L, this).getChanged();<br>
<br>
// Remove any extra phis created by processing inner loops.<br>
Changed |= DeleteDeadPHIs(L->getHeader());<br>
@@ -4826,8 +4801,10 @@<br>
#ifndef NDEBUG<br>
Rewriter.setDebugType(DEBUG_TYPE);<br>
#endif<br>
- unsigned numFolded = Rewriter.<br>
- replaceCongruentIVs(L, &getAnalysis<DominatorTree>(), DeadInsts, TLI);<br>
+ unsigned numFolded =<br>
+ Rewriter.replaceCongruentIVs(L, &getAnalysis<DominatorTree>(),<br>
+ DeadInsts,<br>
+ &getAnalysis<TargetTransformInfo>());<br>
if (numFolded) {<br>
Changed = true;<br>
DeleteTriviallyDeadInstructions(DeadInsts);<br>
<br>
Removed: llvm/trunk/test/Transforms/LoopStrengthReduce/2008-08-14-ShadowIV.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopStrengthReduce/2008-08-14-ShadowIV.ll?rev=171734&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopStrengthReduce/2008-08-14-ShadowIV.ll?rev=171734&view=auto</a><br>
==============================================================================<br>
--- llvm/trunk/test/Transforms/LoopStrengthReduce/2008-08-14-ShadowIV.ll (original)<br>
+++ llvm/trunk/test/Transforms/LoopStrengthReduce/2008-08-14-ShadowIV.ll (removed)<br>
@@ -1,99 +0,0 @@<br>
-; RUN: opt < %s -loop-reduce -S | grep "phi double" | count 1<br>
-<br>
-define void @foobar(i32 %n) nounwind {<br>
-entry:<br>
- icmp eq i32 %n, 0 ; <i1>:0 [#uses=2]<br>
- br i1 %0, label %return, label %bb.nph<br>
-<br>
-bb.nph: ; preds = %entry<br>
- %umax = select i1 %0, i32 1, i32 %n ; <i32> [#uses=1]<br>
- br label %bb<br>
-<br>
-bb: ; preds = %bb, %bb.nph<br>
- %i.03 = phi i32 [ 0, %bb.nph ], [ %indvar.next, %bb ] ; <i32> [#uses=3]<br>
- tail call void @bar( i32 %i.03 ) nounwind<br>
- uitofp i32 %i.03 to double ; <double>:1 [#uses=1]<br>
- tail call void @foo( double %1 ) nounwind<br>
- %indvar.next = add i32 %i.03, 1 ; <i32> [#uses=2]<br>
- %exitcond = icmp eq i32 %indvar.next, %umax ; <i1> [#uses=1]<br>
- br i1 %exitcond, label %return, label %bb<br>
-<br>
-return: ; preds = %bb, %entry<br>
- ret void<br>
-}<br>
-<br>
-; Unable to eliminate cast because the mantissa bits for double are not enough<br>
-; to hold all of i64 IV bits.<br>
-define void @foobar2(i64 %n) nounwind {<br>
-entry:<br>
- icmp eq i64 %n, 0 ; <i1>:0 [#uses=2]<br>
- br i1 %0, label %return, label %bb.nph<br>
-<br>
-bb.nph: ; preds = %entry<br>
- %umax = select i1 %0, i64 1, i64 %n ; <i64> [#uses=1]<br>
- br label %bb<br>
-<br>
-bb: ; preds = %bb, %bb.nph<br>
- %i.03 = phi i64 [ 0, %bb.nph ], [ %indvar.next, %bb ] ; <i64> [#uses=3]<br>
- trunc i64 %i.03 to i32 ; <i32>:1 [#uses=1]<br>
- tail call void @bar( i32 %1 ) nounwind<br>
- uitofp i64 %i.03 to double ; <double>:2 [#uses=1]<br>
- tail call void @foo( double %2 ) nounwind<br>
- %indvar.next = add i64 %i.03, 1 ; <i64> [#uses=2]<br>
- %exitcond = icmp eq i64 %indvar.next, %umax ; <i1> [#uses=1]<br>
- br i1 %exitcond, label %return, label %bb<br>
-<br>
-return: ; preds = %bb, %entry<br>
- ret void<br>
-}<br>
-<br>
-; Unable to eliminate cast due to potentional overflow.<br>
-define void @foobar3() nounwind {<br>
-entry:<br>
- tail call i32 (...)* @nn( ) nounwind ; <i32>:0 [#uses=1]<br>
- icmp eq i32 %0, 0 ; <i1>:1 [#uses=1]<br>
- br i1 %1, label %return, label %bb<br>
-<br>
-bb: ; preds = %bb, %entry<br>
- %i.03 = phi i32 [ 0, %entry ], [ %3, %bb ] ; <i32> [#uses=3]<br>
- tail call void @bar( i32 %i.03 ) nounwind<br>
- uitofp i32 %i.03 to double ; <double>:2 [#uses=1]<br>
- tail call void @foo( double %2 ) nounwind<br>
- add i32 %i.03, 1 ; <i32>:3 [#uses=2]<br>
- tail call i32 (...)* @nn( ) nounwind ; <i32>:4 [#uses=1]<br>
- icmp ugt i32 %4, %3 ; <i1>:5 [#uses=1]<br>
- br i1 %5, label %bb, label %return<br>
-<br>
-return: ; preds = %bb, %entry<br>
- ret void<br>
-}<br>
-<br>
-; Unable to eliminate cast due to overflow.<br>
-define void @foobar4() nounwind {<br>
-entry:<br>
- br label %bb.nph<br>
-<br>
-bb.nph: ; preds = %entry<br>
- br label %bb<br>
-<br>
-bb: ; preds = %bb, %bb.nph<br>
- %i.03 = phi i8 [ 0, %bb.nph ], [ %indvar.next, %bb ] ; <i32> [#uses=3]<br>
- %tmp2 = sext i8 %i.03 to i32 ; <i32>:0 [#uses=1]<br>
- tail call void @bar( i32 %tmp2 ) nounwind<br>
- %tmp3 = uitofp i8 %i.03 to double ; <double>:1 [#uses=1]<br>
- tail call void @foo( double %tmp3 ) nounwind<br>
- %indvar.next = add i8 %i.03, 1 ; <i32> [#uses=2]<br>
- %tmp = sext i8 %indvar.next to i32<br>
- %exitcond = icmp eq i32 %tmp, 32767 ; <i1> [#uses=1]<br>
- br i1 %exitcond, label %return, label %bb<br>
-<br>
-return: ; preds = %bb, %entry<br>
- ret void<br>
-}<br>
-<br>
-declare void @bar(i32)<br>
-<br>
-declare void @foo(double)<br>
-<br>
-declare i32 @nn(...)<br>
-<br>
<br>
Removed: llvm/trunk/test/Transforms/LoopStrengthReduce/2011-07-20-DoubleIV.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopStrengthReduce/2011-07-20-DoubleIV.ll?rev=171734&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopStrengthReduce/2011-07-20-DoubleIV.ll?rev=171734&view=auto</a><br>
==============================================================================<br>
--- llvm/trunk/test/Transforms/LoopStrengthReduce/2011-07-20-DoubleIV.ll (original)<br>
+++ llvm/trunk/test/Transforms/LoopStrengthReduce/2011-07-20-DoubleIV.ll (removed)<br>
@@ -1,43 +0,0 @@<br>
-; RUN: opt < %s -loop-reduce -S | FileCheck %s<br>
-;<br>
-; Test LSR's OptimizeShadowIV. Handle a floating-point IV with a<br>
-; nonzero initial value.<br>
-; rdar://9786536<br>
-<br>
-; First, make sure LSR doesn't crash on an empty IVUsers list.<br>
-; CHECK: @dummyIV<br>
-; CHECK-NOT: phi<br>
-; CHECK-NOT: sitofp<br>
-; CHECK: br<br>
-define void @dummyIV() nounwind {<br>
-entry:<br>
- br label %loop<br>
-<br>
-loop:<br>
- %i.01 = phi i32 [ -39, %entry ], [ %inc, %loop ]<br>
- %conv = sitofp i32 %i.01 to double<br>
- %inc = add nsw i32 %i.01, 1<br>
- br i1 undef, label %loop, label %for.end<br>
-<br>
-for.end:<br>
- unreachable<br>
-}<br>
-<br>
-; Now check that the computed double constant is correct.<br>
-; CHECK: @doubleIV<br>
-; CHECK: phi double [ -3.900000e+01, %entry ]<br>
-; CHECK: br<br>
-define void @doubleIV() nounwind {<br>
-entry:<br>
- br label %loop<br>
-<br>
-loop:<br>
- %i.01 = phi i32 [ -39, %entry ], [ %inc, %loop ]<br>
- %conv = sitofp i32 %i.01 to double<br>
- %div = fdiv double %conv, 4.000000e+01<br>
- %inc = add nsw i32 %i.01, 1<br>
- br i1 undef, label %loop, label %for.end<br>
-<br>
-for.end:<br>
- unreachable<br>
-}<br>
<br>
Modified: llvm/trunk/test/Transforms/LoopStrengthReduce/2012-07-18-LimitReassociate.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopStrengthReduce/2012-07-18-LimitReassociate.ll?rev=171735&r1=171734&r2=171735&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopStrengthReduce/2012-07-18-LimitReassociate.ll?rev=171735&r1=171734&r2=171735&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/Transforms/LoopStrengthReduce/2012-07-18-LimitReassociate.ll (original)<br>
+++ llvm/trunk/test/Transforms/LoopStrengthReduce/2012-07-18-LimitReassociate.ll Mon Jan 7 08:41:08 2013<br>
@@ -5,16 +5,17 @@<br>
; PR13361: LSR + SCEV "hangs" on reasonably sized test with sequence of loops<br>
;<br>
; Without limits on CollectSubexpr, we have thousands of formulae for<br>
-; the use that crosses loops. With limits we have five.<br>
+; the use that crosses loops. With limits we have six.<br>
; CHECK: LSR on loop %bb221:<br>
; CHECK: After generating reuse formulae:<br>
; CHECK: LSR is examining the following uses:<br>
; CHECK: LSR Use: Kind=Special<br>
-; CHECK: {{.*reg\(\{\{\{\{\{\{\{\{\{}}<br>
-; CHECK: {{.*reg\(\{\{\{\{\{\{\{\{\{}}<br>
-; CHECK: {{.*reg\(\{\{\{\{\{\{\{\{\{}}<br>
-; CHECK: {{.*reg\(\{\{\{\{\{\{\{\{\{}}<br>
-; CHECK: {{.*reg\(\{\{\{\{\{\{\{\{\{}}<br>
+; CHECK: {{.*reg\(\{.*\{.*\{.*\{.*\{.*\{.*\{.*\{.*\{}}<br>
+; CHECK: {{.*reg\(\{.*\{.*\{.*\{.*\{.*\{.*\{.*\{.*\{}}<br>
+; CHECK: {{.*reg\(\{.*\{.*\{.*\{.*\{.*\{.*\{.*\{.*\{}}<br>
+; CHECK: {{.*reg\(\{.*\{.*\{.*\{.*\{.*\{.*\{.*\{.*\{}}<br>
+; CHECK: {{.*reg\(\{.*\{.*\{.*\{.*\{.*\{.*\{.*\{.*\{}}<br>
+; CHECK: {{.*reg\(\{.*\{.*\{.*\{.*\{.*\{.*\{.*\{.*\{}}<br>
; CHECK-NOT:reg<br>
; CHECK: Filtering for use<br>
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"<br>
<br>
Copied: llvm/trunk/test/Transforms/LoopStrengthReduce/X86/2008-08-14-ShadowIV.ll (from r171726, llvm/trunk/test/Transforms/LoopStrengthReduce/2008-08-14-ShadowIV.ll)<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopStrengthReduce/X86/2008-08-14-ShadowIV.ll?p2=llvm/trunk/test/Transforms/LoopStrengthReduce/X86/2008-08-14-ShadowIV.ll&p1=llvm/trunk/test/Transforms/LoopStrengthReduce/2008-08-14-ShadowIV.ll&r1=171726&r2=171735&rev=171735&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopStrengthReduce/X86/2008-08-14-ShadowIV.ll?p2=llvm/trunk/test/Transforms/LoopStrengthReduce/X86/2008-08-14-ShadowIV.ll&p1=llvm/trunk/test/Transforms/LoopStrengthReduce/2008-08-14-ShadowIV.ll&r1=171726&r2=171735&rev=171735&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/Transforms/LoopStrengthReduce/2008-08-14-ShadowIV.ll (original)<br>
+++ llvm/trunk/test/Transforms/LoopStrengthReduce/X86/2008-08-14-ShadowIV.ll Mon Jan 7 08:41:08 2013<br>
@@ -1,4 +1,4 @@<br>
-; RUN: opt < %s -loop-reduce -S | grep "phi double" | count 1<br>
+; RUN: opt < %s -loop-reduce -S -mtriple=x86_64-unknown-unknown | grep "phi double" | count 1<br>
<br>
define void @foobar(i32 %n) nounwind {<br>
entry:<br>
<br>
Copied: llvm/trunk/test/Transforms/LoopStrengthReduce/X86/2011-07-20-DoubleIV.ll (from r171726, llvm/trunk/test/Transforms/LoopStrengthReduce/2011-07-20-DoubleIV.ll)<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopStrengthReduce/X86/2011-07-20-DoubleIV.ll?p2=llvm/trunk/test/Transforms/LoopStrengthReduce/X86/2011-07-20-DoubleIV.ll&p1=llvm/trunk/test/Transforms/LoopStrengthReduce/2011-07-20-DoubleIV.ll&r1=171726&r2=171735&rev=171735&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopStrengthReduce/X86/2011-07-20-DoubleIV.ll?p2=llvm/trunk/test/Transforms/LoopStrengthReduce/X86/2011-07-20-DoubleIV.ll&p1=llvm/trunk/test/Transforms/LoopStrengthReduce/2011-07-20-DoubleIV.ll&r1=171726&r2=171735&rev=171735&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/Transforms/LoopStrengthReduce/2011-07-20-DoubleIV.ll (original)<br>
+++ llvm/trunk/test/Transforms/LoopStrengthReduce/X86/2011-07-20-DoubleIV.ll Mon Jan 7 08:41:08 2013<br>
@@ -1,4 +1,4 @@<br>
-; RUN: opt < %s -loop-reduce -S | FileCheck %s<br>
+; RUN: opt < %s -loop-reduce -S -mtriple=x86_64-unknown-unknown | FileCheck %s<br>
;<br>
; Test LSR's OptimizeShadowIV. Handle a floating-point IV with a<br>
; nonzero initial value.<br>
<br>
Modified: llvm/trunk/test/Transforms/LoopStrengthReduce/post-inc-icmpzero.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopStrengthReduce/post-inc-icmpzero.ll?rev=171735&r1=171734&r2=171735&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopStrengthReduce/post-inc-icmpzero.ll?rev=171735&r1=171734&r2=171735&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/Transforms/LoopStrengthReduce/post-inc-icmpzero.ll (original)<br>
+++ llvm/trunk/test/Transforms/LoopStrengthReduce/post-inc-icmpzero.ll Mon Jan 7 08:41:08 2013<br>
@@ -4,12 +4,12 @@<br>
; LSR should properly handle the post-inc offset when folding the<br>
; non-IV operand of an icmp into the IV.<br>
<br>
-; CHECK: %4 = sub i64 %sub.ptr.lhs.cast, %sub.ptr.rhs.cast<br>
-; CHECK: %5 = lshr i64 %4, 1<br>
-; CHECK: %6 = mul i64 %5, 2<br>
+; CHECK: %3 = sub i64 %sub.ptr.lhs.cast, %sub.ptr.rhs.cast<br>
+; CHECK: %4 = lshr i64 %3, 1<br>
+; CHECK: %5 = mul i64 %4, 2<br>
; CHECK: br label %for.body<br>
; CHECK: for.body:<br>
-; CHECK: %lsr.iv2 = phi i64 [ %lsr.iv.next, %for.body ], [ %6, %<a href="http://for.body.lr.ph" target="_blank">for.body.lr.ph</a> ]<br>
+; CHECK: %lsr.iv2 = phi i64 [ %lsr.iv.next, %for.body ], [ %5, %<a href="http://for.body.lr.ph" target="_blank">for.body.lr.ph</a> ]<br>
; CHECK: %lsr.iv.next = add i64 %lsr.iv2, -2<br>
; CHECK: %lsr.iv.next3 = inttoptr i64 %lsr.iv.next to i16*<br>
; CHECK: %cmp27 = icmp eq i16* %lsr.iv.next3, null<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br>