[llvm] [VPlan] Use llvm.masked.{u, s}{div, rem} for predicated division (PR #191377)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Mon May 11 07:57:02 PDT 2026
================
@@ -120,9 +122,8 @@ define void @sdiv_feeding_gep_predicated(ptr %dst, i32 %x, i64 %M, i64 %conv6, i
; CHECK-NEXT: [[VEC_IND:%.*]] = phi <vscale x 2 x i64> [ [[TMP15]], %[[VECTOR_PH]] ], [ [[VEC_IND_NEXT:%.*]], %[[VECTOR_BODY]] ]
; CHECK-NEXT: [[TMP22:%.*]] = icmp ule <vscale x 2 x i64> [[VEC_IND]], [[BROADCAST_SPLAT]]
; CHECK-NEXT: [[TMP23:%.*]] = select <vscale x 2 x i1> [[ACTIVE_LANE_MASK]], <vscale x 2 x i1> [[TMP22]], <vscale x 2 x i1> zeroinitializer
-; CHECK-NEXT: [[TMP24:%.*]] = extractelement <vscale x 2 x i1> [[TMP23]], i32 0
-; CHECK-NEXT: [[TMP25:%.*]] = select i1 [[TMP24]], i64 [[CONV6]], i64 1
-; CHECK-NEXT: [[TMP26:%.*]] = sdiv i64 [[M]], [[TMP25]]
+; CHECK-NEXT: [[TMP12:%.*]] = call <vscale x 2 x i64> @llvm.masked.sdiv.nxv2i64(<vscale x 2 x i64> [[BROADCAST_SPLAT]], <vscale x 2 x i64> [[BROADCAST_SPLAT2]], <vscale x 2 x i1> [[TMP23]])
----------------
lukel97 wrote:
Sorry for the delay in getting back here, taught `narrowToSingleScalar` how to to handle the masked intrinsics in 7f1b3a0009682a2a2fe58c3d8af365445578ea8c
Although in this particular test the original sdiv was actually narrowed by `legalizeAndOptimizeInductions`, which allows narrowing when `vputils::onlyFirstLaneUsed(Def)`. So to maintain the original behaviour I've used `vputils::onlyFirstLaneUsed` as well in `narrowToSingleScalar`.
https://github.com/llvm/llvm-project/pull/191377
More information about the llvm-commits
mailing list