[llvm] [SeparateConstOffsetFromGEP] Support GEP reordering for different types (PR #90802)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue May 7 19:09:27 PDT 2024


================
@@ -972,24 +972,19 @@ SeparateConstOffsetFromGEP::lowerToArithmetics(GetElementPtrInst *Variadic,
 
 bool SeparateConstOffsetFromGEP::reorderGEP(GetElementPtrInst *GEP,
                                             TargetTransformInfo &TTI) {
-  Type *GEPType = GEP->getResultElementType();
+  Type *GEPType = GEP->getSourceElementType();
   // TODO: support reordering for non-trivial GEP chains
   if (GEPType->isAggregateType() || GEP->getNumIndices() != 1)
     return false;
 
   auto PtrGEP = dyn_cast<GetElementPtrInst>(GEP->getPointerOperand());
   if (!PtrGEP)
     return false;
-  Type *PtrGEPType = PtrGEP->getResultElementType();
+  Type *PtrGEPType = PtrGEP->getSourceElementType();
   // TODO: support reordering for non-trivial GEP chains
   if (PtrGEPType->isAggregateType() || PtrGEP->getNumIndices() != 1)
----------------
nikic wrote:

I think you could also drop the isAggregateType() checks now.

https://github.com/llvm/llvm-project/pull/90802


More information about the llvm-commits mailing list