There is an assertion failure in computeOverflowForUnsignedMul
(used in checkOverflow) due to the inner and outer trip counts
having different types. This occurs when the IV has been widened,
but the loop components are not successfully rediscovered.
This is fixed by some refactoring of the code in findLoopComponents
which identifies the trip count of the loop.
Details
- Reviewers
SjoerdMeijer dmgreen simon_tatham
Diff Detail
Unit Tests
Event Timeline
Added else statement with BackedgeTCExt = nullptr to prevent uninitialised value being used
llvm/lib/Transforms/Scalar/LoopFlatten.cpp | ||
---|---|---|
207 | This has become quite complicated logic. I am wondering if we can handle the simple case first to reduce indentation and improve readability: if (SCEVRHS == SCEVTripCount) return setLoopComponents(RHS, Increment); where setLoopComponents is a new helper that includes the code at lines 229 - 233 and sets TripCount. | |
216–217 | Then we can replace next lines with: return setLoopComponents(RHS, Increment); | |
222 | Remove this else and just initialise BackedgeTCExt above? const SCEV *BackedgeTCExt = nullptr; |
llvm/lib/Transforms/Scalar/LoopFlatten.cpp | ||
---|---|---|
207 | I've added a helper - hopefully it's what you had in mind, but I'm happy to change it if not |
llvm/lib/Transforms/Scalar/LoopFlatten.cpp | ||
---|---|---|
97 | Nit: perhaps rename RHS to TC so that it's a bit more descriptive. | |
99 | Nit: don't think this comment adds much, and don't mind if you delete it. I think the function is small and its name descriptive enough. | |
207 | Thanks, that's exactly what I had in mind. I just added a few nits here and there, while I am going to take your patch now and run testing. | |
209 | Nit: I think we can get rid of the else now. |
I've run our downstream benchmarks, and that came back green.
So this looks like a good fix to me.
Nit: perhaps rename RHS to TC so that it's a bit more descriptive.