[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.
This commit is contained in:
Juneyoung Lee 2021-06-24 02:03:07 +09:00
parent 00d3f7cc3c
commit 2fd3037ac6
1 changed files with 1 additions and 8 deletions

View File

@ -1124,14 +1124,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode, Constant *C1,
} }
// Binary operations propagate poison. // Binary operations propagate poison.
// FIXME: Currently, or/and i1 poison aren't folded into poison because if (isa<PoisonValue>(C1) || isa<PoisonValue>(C2))
// 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)))
return PoisonValue::get(C1->getType()); return PoisonValue::get(C1->getType());
// Handle scalar UndefValue and scalable vector UndefValue. Fixed-length // Handle scalar UndefValue and scalable vector UndefValue. Fixed-length