Fixes PR33114 (see https://bugs.llvm.org/show_bug.cgi?id=33114 for discussion).
Details
Diff Detail
Event Timeline
Thanks for catching this.
The patch looks good, just some inline comments to optimize the code.
lib/Transforms/Scalar/LoopIdiomRecognize.cpp | ||
---|---|---|
1042 | I wonder if you need PhiX as a parameter. It looks like it is unused after the call. | |
test/Transforms/LoopIdiom/pr33114.ll | ||
2 | I would mention that the test checks just no assert in comments. |
lib/Transforms/Scalar/LoopIdiomRecognize.cpp | ||
---|---|---|
1042 |
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; } | |
1142 | Can we reuse the new function here for Inst and Inst->getOperand(0)? | |
1258 | And here. |
lib/Transforms/Scalar/LoopIdiomRecognize.cpp | ||
---|---|---|
1142 | 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. |
I wonder if you need PhiX as a parameter. It looks like it is unused after the call.
Also it looks like the function does not modify anything, so you don't need references.