[llvm] 2fd3037 - [ConstantFold] Allow propagation of poison for and/or i1
Juneyoung Lee via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 23 10:04:49 PDT 2021
Author: Juneyoung Lee
Date: 2021-06-24T02:03:09+09:00
New Revision: 2fd3037ac615643fe8058292d2b89bb19a49cb2f
URL: https://github.com/llvm/llvm-project/commit/2fd3037ac615643fe8058292d2b89bb19a49cb2f
DIFF: https://github.com/llvm/llvm-project/commit/2fd3037ac615643fe8058292d2b89bb19a49cb2f.diff
LOG: [ConstantFold] Allow propagation of poison for and/or i1
They were disallowed due to its bad interaction with select i1 -> and/or i1.
The transformation is now disabled by D101191, so let's revive this.
Added:
Modified:
llvm/lib/IR/ConstantFold.cpp
Removed:
################################################################################
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp
index 652ccd3efb31..e2925784953b 100644
--- a/llvm/lib/IR/ConstantFold.cpp
+++ b/llvm/lib/IR/ConstantFold.cpp
@@ -1124,14 +1124,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode, Constant *C1,
}
// Binary operations propagate poison.
- // FIXME: Currently, or/and i1 poison aren't folded into poison because
- // it causes miscompilation when combined with another optimization in
- // InstCombine (select i1 -> and/or). The select fold is wrong, but
- // fixing it requires an effort, so temporarily disable this until it is
- // fixed.
- bool PoisonFold = !C1->getType()->isIntegerTy(1) ||
- (Opcode != Instruction::Or && Opcode != Instruction::And);
- if (PoisonFold && (isa<PoisonValue>(C1) || isa<PoisonValue>(C2)))
+ if (isa<PoisonValue>(C1) || isa<PoisonValue>(C2))
return PoisonValue::get(C1->getType());
// Handle scalar UndefValue and scalable vector UndefValue. Fixed-length
More information about the llvm-commits
mailing list