[llvm] [LV] Scale block costs using BranchFrequencyInfo (PR #71793)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 18 03:01:08 PST 2024
================
@@ -0,0 +1,113 @@
+; RUN: opt -mtriple=riscv64 -mattr=+v -riscv-v-vector-bits-max=128 -riscv-v-register-bit-width-lmul=1 -passes='require<profile-summary>,loop-vectorize' -debug-only=loop-vectorize -disable-output < %s 2>&1 | FileCheck %s
+
+; Check that branch weights make a difference when computing cost of scalar loop
+
+define void @foo_with_wts(ptr %A, ptr %B, i32 %n) {
+; CHECK: LV: Checking a loop in 'foo_with_wts'
+; CHECK: LV: Scalar loop costs: [[COST:[0-9]+]].
+; CHECK-NOT: vector.body
+entry:
+ %cmp8 = icmp sgt i32 %n, 0
+ br i1 %cmp8, label %for.body.preheader, label %for.cond.cleanup
+
+for.body.preheader:
+ %wide.trip.count = zext i32 %n to i64
+ br label %for.body
+
+for.cond.cleanup.loopexit:
+ br label %for.cond.cleanup
+
+for.cond.cleanup:
+ ret void
+
+for.body:
+ %indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.inc ]
+ %0 = trunc i64 %indvars.iv to i32
+ %rem = urem i32 %0, 100
+ %cmp1 = icmp eq i32 %rem, 0
+ br i1 %cmp1, label %if.then, label %for.inc, !prof !0
+
+if.then:
+ %arrayidx = getelementptr inbounds i32, ptr %B, i64 %indvars.iv
+ %1 = load i32, ptr %arrayidx, align 4
+ %arrayidx3 = getelementptr inbounds i32, ptr %A, i64 %indvars.iv
+ %2 = load i32, ptr %arrayidx3, align 4
+ %udiv1 = udiv i32 %2, %1
+ %udiv2 = udiv i32 %2, %1
+ %udiv3 = udiv i32 %2, %1
+ %udiv4 = udiv i32 %2, %1
+ %udiv5 = udiv i32 %2, %1
+ %udiv6 = udiv i32 %2, %1
+ br label %for.inc
+
+for.inc:
+ %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
----------------
fhahn wrote:
drop `indvars.` prefix to make names more compact.
https://github.com/llvm/llvm-project/pull/71793
More information about the llvm-commits
mailing list