It is to fix PR30950. After SimplifyCfg sinking, it will create IR as load(gep(A, select(idx1, idx2)))). Only equipped with the transformation, InstCombine can make the redundent loads hidden by select exposed to GVN.
Diff Detail
Diff Detail
- Repository
- rL LLVM
Event Timeline
lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp | ||
---|---|---|
907–908 | 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)); ... |
lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp | ||
---|---|---|
907–908 | But then NewGEP1 will be used in the if condition before it is created. |
auto *SI