[SCEVExpander] Recompute poison-generating flags on hoisting. PR57187
authorMax Kazantsev <mkazantsev@azul.com>
Tue, 13 Sep 2022 05:31:07 +0000 (12:31 +0700)
committerMax Kazantsev <mkazantsev@azul.com>
Tue, 13 Sep 2022 05:56:35 +0000 (12:56 +0700)
commit86d5586d78d813a6921d786f7ddb1a41c6fb56e0
treea020b9964f25d0f3210d936ebe78bb4816f13e75
parent4531f5385125dd6448004a16cd80a94484ca68b7
[SCEVExpander] Recompute poison-generating flags on hoisting. PR57187

Instruction being hoisted could have nuw/nsw flags inferred from the old
context, and we cannot simply move it to the new location keeping them
because we are going to introduce new uses to them that didn't exist before.

Example in https://github.com/llvm/llvm-project/issues/57187 shows how
this can produce branch by poison from initially well-defined program.

This patch forcefully recomputes poison-generating flag in the new context.

Differential Revision: https://reviews.llvm.org/D132022
Reviewed By: fhahn, nikic
llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h
llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
llvm/test/Transforms/IndVarSimplify/X86/pr57187.ll