[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 16:20:28 PST 2016


majnemer added inline comments.


================
Comment at: lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp:886
+    Value *LastOp = GEPI->getOperand(LastIdx);
+    if (SelectInst *SI = dyn_cast<SelectInst>(LastOp)) {
+      GetElementPtrInst *NewGEP1 = cast<GetElementPtrInst>(GEPI->clone());
----------------
`auto *SI`


================
Comment at: lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp:907-908
+      } else {
+        delete NewGEP1;
+        delete NewGEP2;
+      }
----------------
Do not create IR if you don't think you will use it.


================
Comment at: test/Transforms/InstCombine/load-gep-select.ll:1
+; RUN: opt -instcombine -gvn -S < %s | FileCheck %s
+; PR30950. Check instcombine supports the transformation of load(gep(A, select(I1, I2))) ==> select(load(gep(A, I1)), load(gep(A, I2))), so that global value numbering can remove the redundent loads.
----------------
I'm not sure how I feel about two different passes showing up here.


Repository:
  rL LLVM

https://reviews.llvm.org/D26569





More information about the llvm-commits mailing list