diff options
author | Nikita Popov <npopov@redhat.com> | 2024-02-02 10:52:05 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-02 10:52:05 +0100 |
commit | 5b8e1a6ebf11b6e93bcc96a0d009febe4bb3d7bc (patch) | |
tree | 9b5db67d9753c3e0557db6e425f46df9053ca667 /llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp | |
parent | 42ec9934e1079742e0b5d839e420bc3f746fc73b (diff) | |
download | llvm-5b8e1a6ebf11b6e93bcc96a0d009febe4bb3d7bc.zip llvm-5b8e1a6ebf11b6e93bcc96a0d009febe4bb3d7bc.tar.gz llvm-5b8e1a6ebf11b6e93bcc96a0d009febe4bb3d7bc.tar.bz2 |
[SCEVExpander] Do not reuse disjoint or (#80281)
SCEV treats "or disjoint" the same as "add nsw nuw". However, when
expanding, we cannot generally replace an add SCEV node with an "or
disjoint" instruction. Just dropping the poison flag is insufficient in
this case, we would have to actually convert the or into an add.
This is a partial fix for #79861.
Diffstat (limited to 'llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp index ed55a13..34597e6 100644 --- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp +++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp @@ -1398,6 +1398,13 @@ canReuseInstruction(ScalarEvolution &SE, const SCEV *S, Instruction *I, if (!I) return false; + // Disjoint or instructions are interpreted as adds by SCEV. However, we + // can't replace an arbitrary add with disjoint or, even if we drop the + // flag. We would need to convert the or into an add. + if (auto *PDI = dyn_cast<PossiblyDisjointInst>(I)) + if (PDI->isDisjoint()) + return false; + // FIXME: Ignore vscale, even though it technically could be poison. Do this // because SCEV currently assumes it can't be poison. Remove this special // case once we proper model when vscale can be poison. |