3 Commits

Author SHA1 Message Date
Nikita Popov
7d2b6f0b35
[IndVarSimplify] Fix poison-safety when reusing instructions (#80458)
IndVars may replace an instruction with one of its operands, if they
have the same SCEV expression. However, such a replacement may be more
poisonous.

First, check whether the operand being poison implies that the
instruction is also poison, in which case the replacement is always
safe. If this fails, check whether SCEV can determine that reusing the
instruction is safe, using the same check as SCEVExpander.

Fixes https://github.com/llvm/llvm-project/issues/79861.
2024-02-05 10:11:39 +01:00
Nikita Popov
5b8e1a6ebf
[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.
2024-02-02 10:52:05 +01:00
Nikita Popov
c105848fd2 [IndVars] Add tests for #79861 (NFC) 2024-02-01 12:58:19 +01:00