aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/ConstantFold.cpp
diff options
context:
space:
mode:
authorJuneyoung Lee <aqjune@gmail.com>2020-11-30 22:48:43 +0900
committerJuneyoung Lee <aqjune@gmail.com>2020-11-30 22:58:31 +0900
commit9c49dcc356eb4c59fc1353bbbaae6d3a56a656c1 (patch)
treeb75e8082fa1566e497c78d7b34d17f85c44b29e2 /llvm/lib/IR/ConstantFold.cpp
parentc3d484673fa70bb4b2284689db76d36bbdf12f38 (diff)
downloadllvm-9c49dcc356eb4c59fc1353bbbaae6d3a56a656c1.zip
llvm-9c49dcc356eb4c59fc1353bbbaae6d3a56a656c1.tar.gz
llvm-9c49dcc356eb4c59fc1353bbbaae6d3a56a656c1.tar.bz2
[ConstantFold] Don't fold and/or i1 poison to poison (NFC)
.. because it causes miscompilation when combined with select i1 -> and/or. It is the select fold which is incorrect; but it is costly to disable the fold, so hack this one. D92270
Diffstat (limited to 'llvm/lib/IR/ConstantFold.cpp')
-rw-r--r--llvm/lib/IR/ConstantFold.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp
index 3243ddd..d9564a3 100644
--- a/llvm/lib/IR/ConstantFold.cpp
+++ b/llvm/lib/IR/ConstantFold.cpp
@@ -1105,7 +1105,14 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode, Constant *C1,
}
// Binary operations propagate poison.
- if (isa<PoisonValue>(C1) || isa<PoisonValue>(C2))
+ // 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)))
return PoisonValue::get(C1->getType());
// Handle scalar UndefValue and scalable vector UndefValue. Fixed-length