[llvm] [SeparateConstOffsetFromGEP] Reorder trivial GEP chains to separate constants (PR #73056)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 21 17:59:19 PST 2023


================
@@ -987,11 +987,50 @@ bool SeparateConstOffsetFromGEP::splitGEP(GetElementPtrInst *GEP) {
   bool NeedsExtraction;
   int64_t AccumulativeByteOffset = accumulateByteOffset(GEP, NeedsExtraction);
 
-  if (!NeedsExtraction)
-    return Changed;
-
   TargetTransformInfo &TTI = GetTTI(*GEP->getFunction());
 
+  if (!NeedsExtraction) {
+    // Attempt to reassociate GEPs for better AddrMode construction.
+    if (auto PtrGEP = dyn_cast<GetElementPtrInst>(GEP->getPointerOperand())) {
----------------
arsenm wrote:

Reduce the indentation over the GEP block? Could either separate to a separate function or use C++17 if statement initializers 

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


More information about the llvm-commits mailing list