getExpr is missing a check to make sure the result is invertible.
This can lead to incorrect results, so return nullptr in those cases
like in other places in IVUsers.
Fixes #62660.
Paths
| Differential D153202
[LSR] Return nullptr from getExpr if the result isn't invertible. ClosedPublic Authored by fhahn on Jun 17 2023, 9:48 AM.
Details Summary getExpr is missing a check to make sure the result is invertible. Fixes #62660.
Diff Detail
Unit TestsFailed Event TimelineComment Actions I was wondering if we should have a separate isInvertible API and keep getExpr as is, but a glance at how getExpr is used everywhere tells me that's probably overkill. LGTM This revision is now accepted and ready to land.Jun 19 2023, 12:17 AM Comment Actions Can we change normalizeForPostIncUse() to return nullptr if it does not round trip, so that all users are forced to handle this? Pretty sure this is still going to leave holes behind. Comment Actions
This is something I tried, but the fallout seemed quite big (in terms of test changes) so I think it would be better to incrementally make things stricter. Closed by commit rG3a57152d85e1: [LSR] Return nullptr from getExpr if the result isn't invertible. (authored by fhahn). · Explain WhyJun 22 2023, 11:11 AM This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 532407 llvm/include/llvm/Analysis/IVUsers.h
llvm/lib/Analysis/IVUsers.cpp
llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
llvm/test/Transforms/LoopStrengthReduce/X86/pr62660-normalization-failure.ll
llvm/test/Transforms/LoopStrengthReduce/scaling-factor-incompat-type.ll
|