[all-commits] [llvm/llvm-project] 1c6e64: [SCEVExpander] Fix incorrect reuse of more poisono...
Nikita Popov via All-commits
all-commits at lists.llvm.org
Tue Aug 22 00:27:24 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 1c6e6432ca0b6832e06b93a4bcf22ead1899c14d
https://github.com/llvm/llvm-project/commit/1c6e6432ca0b6832e06b93a4bcf22ead1899c14d
Author: Nikita Popov <npopov at redhat.com>
Date: 2023-08-22 (Tue, 22 Aug 2023)
Changed paths:
M llvm/include/llvm/Analysis/ScalarEvolution.h
M llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h
M llvm/lib/Analysis/ScalarEvolution.cpp
M llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
M llvm/test/CodeGen/Thumb2/mve-blockplacement.ll
M llvm/test/CodeGen/X86/AMX/amx-greedy-ra-spill-shape.ll
M llvm/test/Transforms/IndVarSimplify/pr63763.ll
M llvm/test/Transforms/LoopUnroll/runtime-exit-phi-scev-invalidation.ll
Log Message:
-----------
[SCEVExpander] Fix incorrect reuse of more poisonous instructions (PR63763)
SCEVExpander tries to reuse existing instruction with the same
SCEV expression. However, doing this replacement blindly is not
safe, because the instruction might be more poisonous.
What we were already doing is to drop poison-generating flags on
the reused instruction. But this is not the only way that more
poison can be introduced. The poison-generating flag might not
be directly on the reused instruction, or the poison contribution
might come from something like 0 * %var, which folds to 0 but can
still introduce poison.
This patch fixes the issue in a principled way, by determining which
values can contribute poison to the SCEV expression, and then
checking whether any additional values can contribute poison to the
instruction being reused. Poison-generating flags are dropped if
doing that enables reuse.
This is a pretty big hammer and does cause some regressions in
tests, but less than I would have expected. I wasn't able to come
up with a less intrusive fix that still satisfies the correctness
requirements.
Fixes https://github.com/llvm/llvm-project/issues/63763.
Fixes https://github.com/llvm/llvm-project/issues/63926.
Fixes https://github.com/llvm/llvm-project/issues/64333.
Fixes https://github.com/llvm/llvm-project/issues/63727.
Differential Revision: https://reviews.llvm.org/D158181
More information about the All-commits
mailing list