[PATCH] D26569: [InstCombine] Support load(gep(A, select(idx1, idx2)))) to select(load(gep(A, idx1)), load(gep(A, idx2))) transformation

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 11 20:19:38 PST 2016


majnemer added inline comments.


================
Comment at: lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp:907-908
+      } else {
+        delete NewGEP1;
+        delete NewGEP2;
+      }
----------------
wmi wrote:
> majnemer wrote:
> > Do not create IR if you don't think you will use it.
> But I only need to insert the nodes into IR after isSafeToLoadUnconditionally return true for them.  Any suggestion for this case? 
Something like:
      if (isSafeToLoadUnconditionally(NewGEP1, Align, DL, GEPI) &&
          isSafeToLoadUnconditionally(NewGEP2, Align, DL, GEPI)) {
        GetElementPtrInst *NewGEP1 = cast<GetElementPtrInst>(GEPI->clone());
        GetElementPtrInst *NewGEP2 = cast<GetElementPtrInst>(GEPI->clone());
        NewGEP1->setOperand(LastIdx, SI->getOperand(1));
        NewGEP2->setOperand(LastIdx, SI->getOperand(2));
        ...


Repository:
  rL LLVM

https://reviews.llvm.org/D26569





More information about the llvm-commits mailing list