Fixes PR33114 (see https://bugs.llvm.org/show_bug.cgi?id=33114 for discussion).
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Thanks for catching this.
The patch looks good, just some inline comments to optimize the code.
lib/Transforms/Scalar/LoopIdiomRecognize.cpp | ||
---|---|---|
1042 ↗ | (On Diff #99816) | I wonder if you need PhiX as a parameter. It looks like it is unused after the call. |
test/Transforms/LoopIdiom/pr33114.ll | ||
1 ↗ | (On Diff #99816) | I would mention that the test checks just no assert in comments. |
lib/Transforms/Scalar/LoopIdiomRecognize.cpp | ||
---|---|---|
1042 ↗ | (On Diff #99816) |
Yes. Right. // checks that VarX and DefX create a loop recurrence and return corresponding phi node or NULL otherwise. static PHINode *checkRecurrence(Value *VarX, Instruction *DefX, BasicBlock *LoopEntry) { PhiX = dyn_cast<PHINode>(VarX); if (PhiX && PhiX->getParent() == LoopEntry && (PhiX->getOperand(0) == DefX || PhiX->getOperand(1) == DefX)) return PhiX; return nullptr; } |
1140 ↗ | (On Diff #99816) | Can we reuse the new function here for Inst and Inst->getOperand(0)? |
1255 ↗ | (On Diff #99816) | And here. |
lib/Transforms/Scalar/LoopIdiomRecognize.cpp | ||
---|---|---|
1140 ↗ | (On Diff #99816) | This is NFC, I assume, but we're technically changing the check. If you don't mind, I would do that in a follow-up. |