Skip to content

Commit 4482fd8

Browse files
committed
Revert "[InstCombine] Try to fold trunc(shuffle(zext)) to just a shuffle (llvm#78636)"
This reverts commit 4d11f04. This breaks some programs as mentioned in llvm#78636
1 parent f5e58a0 commit 4482fd8

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,6 @@ Value *InstCombinerImpl::EvaluateInDifferentType(Value *V, Type *Ty,
103103
}
104104
}
105105
break;
106-
case Instruction::ShuffleVector: {
107-
Value *Op0 = EvaluateInDifferentType(I->getOperand(0), Ty, isSigned);
108-
Value *Op1 = EvaluateInDifferentType(I->getOperand(1), Ty, isSigned);
109-
Res = new ShuffleVectorInst(Op0, Op1,
110-
cast<ShuffleVectorInst>(I)->getShuffleMask());
111-
break;
112-
}
113106
default:
114107
// TODO: Can handle more cases here.
115108
llvm_unreachable("Unreachable!");
@@ -370,9 +363,6 @@ static bool canEvaluateTruncated(Value *V, Type *Ty, InstCombinerImpl &IC,
370363
I->getOpcode() == Instruction::FPToSI);
371364
return Ty->getScalarSizeInBits() >= MinBitWidth;
372365
}
373-
case Instruction::ShuffleVector:
374-
return canEvaluateTruncated(I->getOperand(0), Ty, IC, CxtI) &&
375-
canEvaluateTruncated(I->getOperand(1), Ty, IC, CxtI);
376366
default:
377367
// TODO: Can handle more cases here.
378368
break;

llvm/test/Transforms/InstCombine/logical-select-inseltpoison.ll

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -671,8 +671,11 @@ define <4 x i32> @computesignbits_through_shuffles(<4 x float> %x, <4 x float> %
671671

672672
define <4 x i32> @computesignbits_through_two_input_shuffle(<4 x i32> %x, <4 x i32> %y, <4 x i1> %cond1, <4 x i1> %cond2) {
673673
; CHECK-LABEL: @computesignbits_through_two_input_shuffle(
674-
; CHECK-NEXT: [[COND:%.*]] = shufflevector <4 x i1> [[COND1:%.*]], <4 x i1> [[COND2:%.*]], <4 x i32> <i32 0, i32 2, i32 4, i32 6>
675-
; CHECK-NEXT: [[SEL:%.*]] = select <4 x i1> [[COND]], <4 x i32> [[Y:%.*]], <4 x i32> [[X:%.*]]
674+
; CHECK-NEXT: [[SEXT1:%.*]] = sext <4 x i1> [[COND1:%.*]] to <4 x i32>
675+
; CHECK-NEXT: [[SEXT2:%.*]] = sext <4 x i1> [[COND2:%.*]] to <4 x i32>
676+
; CHECK-NEXT: [[COND:%.*]] = shufflevector <4 x i32> [[SEXT1]], <4 x i32> [[SEXT2]], <4 x i32> <i32 0, i32 2, i32 4, i32 6>
677+
; CHECK-NEXT: [[TMP1:%.*]] = trunc <4 x i32> [[COND]] to <4 x i1>
678+
; CHECK-NEXT: [[SEL:%.*]] = select <4 x i1> [[TMP1]], <4 x i32> [[Y:%.*]], <4 x i32> [[X:%.*]]
676679
; CHECK-NEXT: ret <4 x i32> [[SEL]]
677680
;
678681
%sext1 = sext <4 x i1> %cond1 to <4 x i32>

llvm/test/Transforms/InstCombine/logical-select.ll

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -707,8 +707,11 @@ define <4 x i32> @computesignbits_through_shuffles(<4 x float> %x, <4 x float> %
707707

708708
define <4 x i32> @computesignbits_through_two_input_shuffle(<4 x i32> %x, <4 x i32> %y, <4 x i1> %cond1, <4 x i1> %cond2) {
709709
; CHECK-LABEL: @computesignbits_through_two_input_shuffle(
710-
; CHECK-NEXT: [[COND:%.*]] = shufflevector <4 x i1> [[COND1:%.*]], <4 x i1> [[COND2:%.*]], <4 x i32> <i32 0, i32 2, i32 4, i32 6>
711-
; CHECK-NEXT: [[SEL:%.*]] = select <4 x i1> [[COND]], <4 x i32> [[Y:%.*]], <4 x i32> [[X:%.*]]
710+
; CHECK-NEXT: [[SEXT1:%.*]] = sext <4 x i1> [[COND1:%.*]] to <4 x i32>
711+
; CHECK-NEXT: [[SEXT2:%.*]] = sext <4 x i1> [[COND2:%.*]] to <4 x i32>
712+
; CHECK-NEXT: [[COND:%.*]] = shufflevector <4 x i32> [[SEXT1]], <4 x i32> [[SEXT2]], <4 x i32> <i32 0, i32 2, i32 4, i32 6>
713+
; CHECK-NEXT: [[TMP1:%.*]] = trunc <4 x i32> [[COND]] to <4 x i1>
714+
; CHECK-NEXT: [[SEL:%.*]] = select <4 x i1> [[TMP1]], <4 x i32> [[Y:%.*]], <4 x i32> [[X:%.*]]
712715
; CHECK-NEXT: ret <4 x i32> [[SEL]]
713716
;
714717
%sext1 = sext <4 x i1> %cond1 to <4 x i32>

0 commit comments

Comments
 (0)