Skip to content

Commit b33938d

Browse files
committed
[InstCombine] remove overzealous assert for shuffles (PR41419)
As the TODO indicates, instsimplify could be improved. Should fix: https://bugs.llvm.org/show_bug.cgi?id=41419 llvm-svn: 357910
1 parent b4f1bfa commit b33938d

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,8 +1353,8 @@ static Instruction *foldSelectShuffle(ShuffleVectorInst &Shuf,
13531353
// Canonicalize to choose from operand 0 first.
13541354
unsigned NumElts = Shuf.getType()->getVectorNumElements();
13551355
if (Shuf.getMaskValue(0) >= (int)NumElts) {
1356-
assert(!isa<UndefValue>(Shuf.getOperand(1)) &&
1357-
"Not expecting undef shuffle operand with select mask");
1356+
// TODO: Can we assert that both operands of a shuffle-select are not undef
1357+
// (otherwise, it would have been folded by instsimplify?
13581358
Shuf.commute();
13591359
return &Shuf;
13601360
}

llvm/test/Transforms/InstCombine/shuffle_select.ll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1454,3 +1454,13 @@ define <4 x i8> @or_add_2_vars(<4 x i8> %v, <4 x i8> %v1) {
14541454
ret <4 x i8> %t3
14551455
}
14561456

1457+
; The undef operand is used to simplify the shuffle mask, but don't assert that too soon.
1458+
1459+
define <4 x i32> @PR41419(<4 x i32> %v) {
1460+
; CHECK-LABEL: @PR41419(
1461+
; CHECK-NEXT: ret <4 x i32> [[V:%.*]]
1462+
;
1463+
%s = shufflevector <4 x i32> %v, <4 x i32> undef, <4 x i32> <i32 4, i32 5, i32 2, i32 7>
1464+
ret <4 x i32> %s
1465+
}
1466+

0 commit comments

Comments
 (0)