Skip to content

Commit dd1e8e8

Browse files
committed
Fix using old CTy instead of NewCTy for scalable splat
1 parent bbbac68 commit dd1e8e8

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

llvm/lib/Transforms/InstCombine/InstructionCombining.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2106,8 +2106,7 @@ static Constant *unshuffleConstant(ArrayRef<int> ShMask, Constant *C,
21062106
Constant *Splat = C->getSplatValue();
21072107
if (!Splat)
21082108
return nullptr;
2109-
return ConstantVector::getSplat(
2110-
cast<VectorType>(C->getType())->getElementCount(), Splat);
2109+
return ConstantVector::getSplat(NewCTy->getElementCount(), Splat);
21112110
}
21122111

21132112
if (cast<FixedVectorType>(NewCTy)->getNumElements() >

llvm/test/Transforms/InstCombine/vec_shuffle.ll

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,17 @@ define <4 x i8> @widening_shuffle_add_1(<2 x i8> %x) {
652652
ret <4 x i8> %r
653653
}
654654

655+
define <vscale x 4 x i8> @widening_shuffle_add_1_scalable(<vscale x 2 x i8> %x) {
656+
; CHECK-LABEL: @widening_shuffle_add_1_scalable(
657+
; CHECK-NEXT: [[TMP1:%.*]] = add <vscale x 2 x i8> [[X:%.*]], splat (i8 42)
658+
; CHECK-NEXT: [[R:%.*]] = shufflevector <vscale x 2 x i8> [[TMP1]], <vscale x 2 x i8> poison, <vscale x 4 x i32> zeroinitializer
659+
; CHECK-NEXT: ret <vscale x 4 x i8> [[R]]
660+
;
661+
%widex = shufflevector <vscale x 2 x i8> %x, <vscale x 2 x i8> undef, <vscale x 4 x i32> zeroinitializer
662+
%r = add <vscale x 4 x i8> %widex, splat (i8 42)
663+
ret <vscale x 4 x i8> %r
664+
}
665+
655666
; Reduce the width of the binop by moving it ahead of a shuffle.
656667

657668
define <4 x i8> @widening_shuffle_add_2(<2 x i8> %x) {

0 commit comments

Comments
 (0)