[PATCH] D29885: [LSR] Pointers with different address spaces are considered incompatible.

Mikael Holmén via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 13 01:26:30 PST 2017


uabelho created this revision.
Herald added a subscriber: mzolotukhin.

Function isCompatibleIVType is already used as a guard before the call to

SE.getMinusSCEV(OperExpr, PrevExpr);

in LSRInstance::ChainInstruction. getMinusSCEV requires the expressions
to be of the same type, so we now consider two pointers with different
address spaces to be incompatible, since it is possible that the pointers
in fact have different sizes.

Unfortunately I haven't been able to reproduce this an on in-tree target
since I don't know of any such target with different pointer sizes for
different address spaces. Therefore no test case. :(


https://reviews.llvm.org/D29885

Files:
  lib/Transforms/Scalar/LoopStrengthReduce.cpp


Index: lib/Transforms/Scalar/LoopStrengthReduce.cpp
===================================================================
--- lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -2559,7 +2559,12 @@
 static bool isCompatibleIVType(Value *LVal, Value *RVal) {
   Type *LType = LVal->getType();
   Type *RType = RVal->getType();
-  return (LType == RType) || (LType->isPointerTy() && RType->isPointerTy());
+  return (LType == RType) || (LType->isPointerTy() && RType->isPointerTy() &&
+                              // Different address spaces means (possibly)
+                              // different types of the pointer implementation,
+                              // e.g. i16 vs i32 so disallow that.
+                              (LType->getPointerAddressSpace() ==
+                               RType->getPointerAddressSpace()));
 }
 
 /// Return an approximation of this SCEV expression's "base", or NULL for any


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29885.88165.patch
Type: text/x-patch
Size: 969 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170213/e9d6779c/attachment.bin>


More information about the llvm-commits mailing list