This is an archive of the discontinued LLVM Phabricator instance.

[LoopStrengthReduction] Fix pointer to int extend asserts
ClosedPublic

Authored by bcahoon on Jul 30 2021, 10:41 AM.

Details

Summary

Additional asserts were added to ScalarEvolution to enforce
pointer/int type rules. An assert is triggered when the LSR pass
attempts to extend a pointer SCEV to an int SCEV in
GenerateTruncates.

Diff Detail

Event Timeline

bcahoon created this revision.Jul 30 2021, 10:41 AM
bcahoon requested review of this revision.Jul 30 2021, 10:41 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 30 2021, 10:41 AM
efriedma added inline comments.
llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
4082

Should we force Formula::getType() to always return an integer type, to avoid confusion like this in the future?

4101

This doesn't look right; I think if F.ScaledReg->getType()->isPointerTy() is true, you need to "continue", so we don't try to use a partially-transformed formula?

bcahoon updated this revision to Diff 363187.Jul 30 2021, 12:54 PM

Moved checks for pointer type in ScaledReg and BaseRegs to outside the loop.

bcahoon added inline comments.Jul 30 2021, 12:58 PM
llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
4082

I'm not sure that would be correct?

4101

Thanks! I moved this check to occur prior to the loop.

efriedma accepted this revision.Jul 30 2021, 1:24 PM

LGTM

llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
4082

At the moment, Formula::getType() is picking the type of a random part of the formula, basically. It seems like picking consistently would be an improvement?

(In any case, doesn't need to be part of this patch.)

This revision is now accepted and ready to land.Jul 30 2021, 1:24 PM
This revision was automatically updated to reflect the committed changes.