[llvm] [LoopInterchange] Forbid interchange if load store type wider than element type (PR #77885)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 24 21:14:17 PST 2024
================
@@ -82,6 +82,40 @@ static void printDepMatrix(CharMatrix &DepMatrix) {
}
#endif
+// Consider the following case, interchange is not valid as the store type(int)
+// is wider than the array element type(char).
+//
+// char p[7];
+// for (int j = 0; j < 2; ++j)
+// for (int i = 0; i < 2; ++i)
+// *((int*)&p[2*i+j]) = 2*i+j+1;
+//
+// Return true if the load/store type is wider than the element type.
+static bool isWiderLoadStore(Instruction *I) {
+ Value *Ptr = getLoadStorePointerOperand(I);
+ Type *ITy = getLoadStoreType(I);
+
+ if (!ITy->isSingleValueType())
+ return false;
+
+ if (auto *GEP = dyn_cast<GetElementPtrInst>(Ptr)) {
+ Type *ElementTy = GEP->getSourceElementType();
----------------
ShivaChen wrote:
Thanks for the information. I was mimicking how the delinearization extract the subscripts. I assume we should not increase the dependency to GEP. Thanks.
https://github.com/llvm/llvm-project/pull/77885
More information about the llvm-commits
mailing list