Skip to content

Commit e9d51e7

Browse files
committed
Update comment, add test for ub
1 parent 401ffa6 commit e9d51e7

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

llvm/lib/Transforms/InstCombine/InstructionCombining.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2272,7 +2272,7 @@ Instruction *InstCombinerImpl::foldVectorBinop(BinaryOperator &Inst) {
22722272
}
22732273

22742274
// Similar to the combine above, but handles the case for scalable vectors
2275-
// where both V1 and C are splats.
2275+
// where both shuffle(V1, 0) and C are splats.
22762276
//
22772277
// Op(shuffle(V1, 0), (splat C)) -> shuffle(Op(V1, (splat C)), 0)
22782278
if (isa<ScalableVectorType>(Inst.getType()) &&

llvm/test/Transforms/InstCombine/vec_shuffle-inseltpoison.ll

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1812,3 +1812,16 @@ define <vscale x 4 x float> @scalable_splat_binop_constant_lhs(<vscale x 4 x flo
18121812
%r = fadd <vscale x 4 x float> splat (float 42.0), %splatx
18131813
ret <vscale x 4 x float> %r
18141814
}
1815+
1816+
; Negative test - shouldn't pull shuffle out as it udiv isn't safe to speculate.
1817+
define <vscale x 4 x i32> @scalable_splat_binop_constant_ub(<vscale x 4 x i32> %x) {
1818+
; CHECK-LABEL: @scalable_splat_binop_constant_ub(
1819+
; CHECK-NEXT: [[SPLATX:%.*]] = shufflevector <vscale x 4 x i32> [[X:%.*]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
1820+
; CHECK-NEXT: [[R:%.*]] = udiv <vscale x 4 x i32> splat (i32 42), [[SPLATX]]
1821+
; CHECK-NEXT: ret <vscale x 4 x i32> [[R]]
1822+
;
1823+
1824+
%splatx = shufflevector <vscale x 4 x i32> %x, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
1825+
%r = udiv <vscale x 4 x i32> splat (i32 42), %splatx
1826+
ret <vscale x 4 x i32> %r
1827+
}

0 commit comments

Comments
 (0)