[llvm] [InstCombine] Check for undef before transforming lshr (mul (X, 2^N + 1)), N -> add (X, lshr(X, N)) (PR #96324)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 23 07:38:24 PDT 2024
================
@@ -1499,7 +1499,7 @@ Instruction *InstCombinerImpl::visitLShr(BinaryOperator &I) {
return replaceInstUsesWith(I, X);
// lshr (mul nuw (X, 2^N + 1)), N -> add nuw (X, lshr(X, N))
- if (Op0->hasOneUse()) {
+ if (Op0->hasOneUse() && isGuaranteedNotToBeUndef(X, &AC, &I, &DT)) {
----------------
nikic wrote:
We should do `if (!isGuaranteedNotToBeUndef) CreateFreeze` instead.
https://github.com/llvm/llvm-project/pull/96324
More information about the llvm-commits
mailing list