Skip to content

Commit c60a58f

Browse files
[InstCombine] Add check of i1 types in select-to-zext/sext transformation
When doing select-to-zext/sext transformations, we should not handle TrueVal and FalseVal of i1 type otherwise it would result in zext/sext i1 to i1. Reviewed By: spatel Differential Revision: https://reviews.llvm.org/D93272
1 parent 6bbb04a commit c60a58f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2606,7 +2606,10 @@ Instruction *InstCombinerImpl::visitSelectInst(SelectInst &SI) {
26062606
// select i1 %c, <2 x i8> <1, 1>, <2 x i8> <0, 0>
26072607
// because that may need 3 instructions to splat the condition value:
26082608
// extend, insertelement, shufflevector.
2609-
if (SelType->isIntOrIntVectorTy() &&
2609+
//
2610+
// Do not handle i1 TrueVal and FalseVal otherwise would result in
2611+
// zext/sext i1 to i1.
2612+
if (SelType->isIntOrIntVectorTy() && !SelType->isIntOrIntVectorTy(1) &&
26102613
CondVal->getType()->isVectorTy() == SelType->isVectorTy()) {
26112614
// select C, 1, 0 -> zext C to int
26122615
if (match(TrueVal, m_One()) && match(FalseVal, m_Zero()))

0 commit comments

Comments
 (0)