[PATCH] D93065: [InstCombine] Disable optimizations of select instructions that causes propagation of poison values
Congzhe Cao via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 14 13:36:20 PST 2020
congzhe updated this revision to Diff 311691.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D93065/new/
https://reviews.llvm.org/D93065
Files:
llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
Index: llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
===================================================================
--- llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -2626,49 +2626,16 @@
CmpInst::Predicate Pred;
- if (SelType->isIntOrIntVectorTy(1) &&
- TrueVal->getType() == CondVal->getType()) {
- if (match(TrueVal, m_One())) {
- // Change: A = select B, true, C --> A = or B, C
- return BinaryOperator::CreateOr(CondVal, FalseVal);
- }
- if (match(TrueVal, m_Zero())) {
- // Change: A = select B, false, C --> A = and !B, C
- Value *NotCond = Builder.CreateNot(CondVal, "not." + CondVal->getName());
- return BinaryOperator::CreateAnd(NotCond, FalseVal);
- }
- if (match(FalseVal, m_Zero())) {
- // Change: A = select B, C, false --> A = and B, C
- return BinaryOperator::CreateAnd(CondVal, TrueVal);
- }
- if (match(FalseVal, m_One())) {
- // Change: A = select B, C, true --> A = or !B, C
- Value *NotCond = Builder.CreateNot(CondVal, "not." + CondVal->getName());
- return BinaryOperator::CreateOr(NotCond, TrueVal);
- }
-
- // select a, a, b -> a | b
- // select a, b, a -> a & b
- if (CondVal == TrueVal)
- return BinaryOperator::CreateOr(CondVal, FalseVal);
- if (CondVal == FalseVal)
- return BinaryOperator::CreateAnd(CondVal, TrueVal);
-
- // select a, ~a, b -> (~a) & b
- // select a, b, ~a -> (~a) | b
- if (match(TrueVal, m_Not(m_Specific(CondVal))))
- return BinaryOperator::CreateAnd(TrueVal, FalseVal);
- if (match(FalseVal, m_Not(m_Specific(CondVal))))
- return BinaryOperator::CreateOr(TrueVal, FalseVal);
- }
-
// Selecting between two integer or vector splat integer constants?
//
// Note that we don't handle a scalar select of vectors:
// select i1 %c, <2 x i8> <1, 1>, <2 x i8> <0, 0>
// because that may need 3 instructions to splat the condition value:
// extend, insertelement, shufflevector.
- if (SelType->isIntOrIntVectorTy() &&
+ //
+ // Do not handle i1 TrueVal and FalseVal otherwise would result in
+ // zext i1 to i1.
+ if (SelType->isIntOrIntVectorTy() && !SelType->isIntOrIntVectorTy(1) &&
CondVal->getType()->isVectorTy() == SelType->isVectorTy()) {
// select C, 1, 0 -> zext C to int
if (match(TrueVal, m_One()) && match(FalseVal, m_Zero()))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93065.311691.patch
Type: text/x-patch
Size: 2439 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201214/73a044c7/attachment.bin>
More information about the llvm-commits
mailing list