diff options
author | Florian Hahn <flo@fhahn.com> | 2025-02-11 13:03:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-11 13:03:12 +0100 |
commit | e258bca9505f35e0a22cb213a305eea9b76d11ea (patch) | |
tree | 39d072acb78b665df89b1442e0f5e63240b1e3bf /llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp | |
parent | 2a5050aa5ef56b01cf4a8f73e0d0eddd6d9ce2a9 (diff) | |
download | llvm-e258bca9505f35e0a22cb213a305eea9b76d11ea.zip llvm-e258bca9505f35e0a22cb213a305eea9b76d11ea.tar.gz llvm-e258bca9505f35e0a22cb213a305eea9b76d11ea.tar.bz2 |
[VPlan] Only skip expansion for SCEVUnknown if it isn't an instruction. (#125235)
Update getOrCreateVPValueForSCEVExpr to only skip expansion of
SCEVUnknown if the underlying value isn't an instruction. Instructions
may be defined in a loop and using them without expansion may break
LCSSA form. SCEVExpander will take care of preserving LCSSA if needed.
We could also try to pass LoopInfo, but there are some users of the
function where it won't be available and main benefit from skipping
expansion is slightly more concise VPlans.
Note that SCEVExpander is now used to expand SCEVUnknown with floats.
Adjust the check in expandCodeFor to only check the types and casts if
the type of the value is different to the requested type. Otherwise we
crash when trying to expand a float and requesting a float type.
Fixes https://github.com/llvm/llvm-project/issues/121518.
PR: https://github.com/llvm/llvm-project/pull/125235
Diffstat (limited to 'llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp index 3a761bc..d429fe9 100644 --- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp +++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp @@ -1451,7 +1451,7 @@ Value *SCEVExpander::expandCodeFor(const SCEV *SH, Type *Ty) { // Expand the code for this SCEV. Value *V = expand(SH); - if (Ty) { + if (Ty && Ty != V->getType()) { assert(SE.getTypeSizeInBits(Ty) == SE.getTypeSizeInBits(SH->getType()) && "non-trivial casts should be done with the SCEVs directly!"); V = InsertNoopCastOfTo(V, Ty); |