OSDN Git Service

SLSR: Use UnknownAddressSpace instead of 0 for pure arithmetic.
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Wed, 27 Apr 2016 00:32:09 +0000 (00:32 +0000)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Wed, 27 Apr 2016 00:32:09 +0000 (00:32 +0000)
In the case where isLegalAddressingMode is used for cases
not related to addressing modes, such as pure adds and muls,
it should not be using address space 0. LSR already passes -1
as the address space in these cases.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267645 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/StraightLineStrengthReduce.cpp

index 03de393..c9761b7 100644 (file)
@@ -74,6 +74,8 @@ using namespace PatternMatch;
 
 namespace {
 
+static const unsigned UnknownAddressSpace = ~0u;
+
 class StraightLineStrengthReduce : public FunctionPass {
 public:
   // SLSR candidate. Such a candidate must be in one of the forms described in
@@ -276,7 +278,7 @@ static bool isGEPFoldable(GetElementPtrInst *GEP,
 static bool isAddFoldable(const SCEV *Base, ConstantInt *Index, Value *Stride,
                           TargetTransformInfo *TTI) {
   return TTI->isLegalAddressingMode(Base->getType(), nullptr, 0, true,
-                                    Index->getSExtValue());
+                                    Index->getSExtValue(), UnknownAddressSpace);
 }
 
 bool StraightLineStrengthReduce::isFoldable(const Candidate &C,