[llvm] [VPlan] Sink single-scalar VPI to replicate regions (PR #208906)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 19 00:08:58 PDT 2026


================
@@ -216,7 +216,8 @@ define void @single_incoming_needs_predication(i64 %a, i64 %b) {
 ; CHECK-NEXT:    [[TMP9:%.*]] = extractelement <2 x i1> [[TMP2]], i64 1
 ; CHECK-NEXT:    br i1 [[TMP9]], label [[PRED_LOAD_IF1:%.*]], label [[PRED_LOAD_CONTINUE2]]
 ; CHECK:       pred.load.if1:
-; CHECK-NEXT:    [[TMP10:%.*]] = add i16 [[TMP1]], 1
+; CHECK-NEXT:    [[TMP17:%.*]] = trunc i64 [[INDEX]] to i16
----------------
lukel97 wrote:

Now we execute the instruction up to VF x UF times if the predicated blocks are all taken. This replicate region is predicated on the header mask so we can expect the predicated blocks to be almost always taken except on the last iteration. 

This is also the opposite transform that GVNHoist makes: https://godbolt.org/z/s1vG71c3x

https://github.com/llvm/llvm-project/pull/208906


More information about the llvm-commits mailing list