[llvm] [VPlan] Give zero-weight edges minimum probability. (PR #226150)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 24 07:09:45 PDT 2026
================
@@ -67,6 +67,67 @@ exit:
ret void
}
+define void @single_pred_zero_weight(ptr noalias %a, ptr noalias %b, ptr noalias %idx) {
+; %if.then is only entered via an edge with zero branch weight. BFI treats the
+; edge as cold, not as never taken, and gives %if.then the minimum non-zero
+; frequency of 2^-31.
+;
+; %loop 1 = 1
+; %if.then 2^-31 ~ 4.66e-10
+; %latch 1 = 1
+;
+; BFI-LABEL: block-frequency-info: single_pred_zero_weight
+; BFI-NEXT: - entry: float = 1.0,
+; BFI-NEXT: - loop: float = 1000.0,
+; BFI-NEXT: - if.then: float = 0.00000046566,
+; BFI-NEXT: - latch: float = 1000.0,
+; BFI-NEXT: - exit: float = 1.0,
+;
+; VPLAN-LABEL: VPlan for loop in 'single_pred_zero_weight'
+; VPLAN: vector.body:
+; VPLAN-NEXT: ir<%iv> = WIDEN-INDUCTION ir<0>, ir<1>, vp<%{{.+}}>
+; VPLAN-NEXT: EMIT ir<%gep.idx> = getelementptr inbounds ir<%idx>, ir<%iv>
+; VPLAN-NEXT: EMIT-SCALAR ir<%i> = load ir<%gep.idx>
+; VPLAN-NEXT: EMIT ir<%gep.b> = getelementptr inbounds ir<%b>, ir<%iv>
+; VPLAN-NEXT: EMIT store ir<%i>, ir<%gep.b>{{$}}
+; VPLAN-NEXT: EMIT ir<%c.0> = icmp sgt ir<%i>, ir<0>
+; VPLAN-NEXT: Successor(s): if.then
+; VPLAN-EMPTY:
+; VPLAN-NEXT: if.then:
+; VPLAN-NEXT: EMIT ir<%gep.a> = getelementptr inbounds ir<%a>, ir<%iv>
+; VPLAN-NEXT: EMIT store ir<%i>, ir<%gep.a>, ir<%c.0> (!vplan.execution.frequency 4294967296 (4.657e-08%))
+; VPLAN-NEXT: Successor(s): latch
+; VPLAN-EMPTY:
+; VPLAN-NEXT: latch:
+; VPLAN-NEXT: EMIT ir<%iv.next> = add ir<%iv>, ir<1>
+; VPLAN-NEXT: EMIT ir<%ec> = icmp eq ir<%iv.next>, ir<1024>
----------------
david-arm wrote:
Seems like we don't print out the execution frequency of the comparison here so we can't see frequencies for the latch.
https://github.com/llvm/llvm-project/pull/226150
More information about the llvm-commits
mailing list