We should not clone stored values unless they are GEPs that are special cased to avoid hoisting them without hoisting their associated ld/st.
Details
Details
Diff Detail
Diff Detail
- Repository
- rL LLVM
Event Timeline
| llvm/lib/Transforms/Scalar/GVNHoist.cpp | ||
|---|---|---|
| 586 ↗ | (On Diff #64967) | We could put the check here: ...
GetElementPtrInst *Val = nullptr;
if (auto *St = dyn_cast<StoreInst>(Repl)) {
Gep = ...
Val = dyn_cast<GetElementPtrInst>(St->getValueOperand()); |
| llvm/lib/Transforms/Scalar/GVNHoist.cpp | ||
|---|---|---|
| 586 ↗ | (On Diff #64967) | I think this is not possible: we need to check whether the stored value is available at HoistPt. |
| llvm/lib/Transforms/Scalar/GVNHoist.cpp | ||
|---|---|---|
| 588 ↗ | (On Diff #64974) | I think you want "Val && !DT->dominates(Val->getParent(), HoistPt)", or something like that? You care whether the value itself is available, not its operands. |
| llvm/lib/Transforms/Scalar/GVNHoist.cpp | ||
|---|---|---|
| 588 ↗ | (On Diff #64974) | This is correct. We do not need to check all operands of the Val instruction. |
Comment Actions
For everything except GEPs, only check that the stored value is available: do not check the availability of the operands.
Comment Actions
You're missing an allOperandsAvailable call if Val is a GEP. (I'm not sure why you're even trying to special-case GEPs here.)