[PATCH] D98512: [LoopVectorize] Simplify scalar cost calculation in getInstructionCost
David Sherwood via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 15 03:54:25 PDT 2021
david-arm added a comment.
Hi @fhahn, I tested the example you pasted above before and after applying my patch and got this debug output:
Before:
LV: Found an estimated cost of 0 for VF 4 For instruction: %i = phi i32 [ 0, %entry ], [ %i.next, %for.body ]
LV: Found an estimated cost of 0 for VF 4 For instruction: %tmp0 = getelementptr half, half* %b, i32 %i
LV: Found an estimated cost of 3 for VF 4 For instruction: %lv = load half, half* %tmp0, align 2
LV: Found an estimated cost of 2 for VF 4 For instruction: %add = fadd half %lv, 0xH5100
LV: Found an estimated cost of 23 for VF 4 For instruction: store half %add, half* %tmp0, align 1
LV: Found an estimated cost of 4 for VF 4 For instruction: %i.next = add nuw nsw i32 %i, 3
LV: Found an estimated cost of 1 for VF 4 For instruction: %cond = icmp eq i32 %i.next, %n
LV: Found an estimated cost of 0 for VF 4 For instruction: br i1 %cond, label %for.end, label %for.body
After:
LV: Found an estimated cost of 0 for VF 4 For instruction: %i = phi i32 [ 0, %entry ], [ %i.next, %for.body ]
LV: Found an estimated cost of 0 for VF 4 For instruction: %tmp0 = getelementptr half, half* %b, i32 %i
LV: Found an estimated cost of 3 for VF 4 For instruction: %lv = load half, half* %tmp0, align 2
LV: Found an estimated cost of 2 for VF 4 For instruction: %add = fadd half %lv, 0xH5100
LV: Found an estimated cost of 23 for VF 4 For instruction: store half %add, half* %tmp0, align 1
LV: Found an estimated cost of 1 for VF 4 For instruction: %i.next = add nuw nsw i32 %i, 3
LV: Found an estimated cost of 1 for VF 4 For instruction: %cond = icmp eq i32 %i.next, %n
LV: Found an estimated cost of 0 for VF 4 For instruction: br i1 %cond, label %for.end, label %for.body
It looks like the only change is the IV update which goes from 4 -> 1. I think the adds you mentioned are included as part of the load/store cost.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D98512/new/
https://reviews.llvm.org/D98512
More information about the llvm-commits
mailing list