You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This patch implements getCFInstrCost TTI hook that mostly affects
LoopVectorizer decisions. It sets zero cost for PHI nodes and zero
throughput cost for branches (assuming that branches are likely to
be predicted). The implementation is similar to X86/AArch64/PowerPC
targets and reduces loop cost by excluding induction PHIs/loop latch
branches, which in turn leads to selecting smaller vectorization
factor.
Copy file name to clipboardExpand all lines: llvm/test/Analysis/CostModel/RISCV/abs.ll
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -75,7 +75,7 @@ define i32 @abs(i32 %arg) {
75
75
; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %30 = call <vscale x 16 x i8> @llvm.abs.nxv16i8(<vscale x 16 x i8> undef, i1 false)
76
76
; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %31 = call <vscale x 32 x i8> @llvm.abs.nxv32i8(<vscale x 32 x i8> undef, i1 false)
77
77
; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %32 = call <vscale x 64 x i8> @llvm.abs.nxv64i8(<vscale x 64 x i8> undef, i1 false)
78
-
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 undef
78
+
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 undef
79
79
;
80
80
call <2 x i64> @llvm.abs.v2i64(<2 x i64> undef, i1false)
81
81
call <4 x i64> @llvm.abs.v4i64(<4 x i64> undef, i1false)
@@ -114,4 +114,4 @@ define i32 @abs(i32 %arg) {
114
114
call <vscale x 64 x i8> @llvm.abs.nxv64i8(<vscale x 64 x i8> undef, i1false)
Copy file name to clipboardExpand all lines: llvm/test/Analysis/CostModel/RISCV/active_lane_mask.ll
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,7 @@ define void @get_lane_mask() {
25
25
; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %mask_v2i1_i32 = call <2 x i1> @llvm.get.active.lane.mask.v2i1.i32(i32 undef, i32 undef)
26
26
; CHECK-NEXT: Cost Model: Found an estimated cost of 22 for instruction: %mask_v32i1_i64 = call <32 x i1> @llvm.get.active.lane.mask.v32i1.i64(i64 undef, i64 undef)
27
27
; CHECK-NEXT: Cost Model: Found an estimated cost of 5 for instruction: %mask_v16i1_i16 = call <16 x i1> @llvm.get.active.lane.mask.v16i1.i16(i16 undef, i16 undef)
28
-
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret void
28
+
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
29
29
;
30
30
%mask_nxv16i1_i64 = call <vscale x 16 x i1> @llvm.get.active.lane.mask.nxv16i1.i64(i64undef, i64undef)
31
31
%mask_nxv8i1_i64 = call <vscale x 8 x i1> @llvm.get.active.lane.mask.nxv8i1.i64(i64undef, i64undef)
Copy file name to clipboardExpand all lines: llvm/test/Analysis/CostModel/RISCV/arith-fp.ll
+9-9Lines changed: 9 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -38,7 +38,7 @@ define i32 @fadd() {
38
38
; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %NXV2F64 = fadd <vscale x 2 x double> undef, undef
39
39
; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %NXV4F64 = fadd <vscale x 4 x double> undef, undef
40
40
; CHECK-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %NXV8F64 = fadd <vscale x 8 x double> undef, undef
41
-
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 undef
41
+
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 undef
42
42
;
43
43
%F16 = faddhalfundef, undef
44
44
%F32 = faddfloatundef, undef
@@ -118,7 +118,7 @@ define i32 @fsub() {
118
118
; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %NXV2F64 = fsub <vscale x 2 x double> undef, undef
119
119
; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %NXV4F64 = fsub <vscale x 4 x double> undef, undef
120
120
; CHECK-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %NXV8F64 = fsub <vscale x 8 x double> undef, undef
121
-
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 undef
121
+
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 undef
122
122
;
123
123
%F16 = fsubhalfundef, undef
124
124
%F32 = fsubfloatundef, undef
@@ -198,7 +198,7 @@ define i32 @fmul() {
198
198
; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %NXV2F64 = fmul <vscale x 2 x double> undef, undef
199
199
; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %NXV4F64 = fmul <vscale x 4 x double> undef, undef
200
200
; CHECK-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %NXV8F64 = fmul <vscale x 8 x double> undef, undef
201
-
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 undef
201
+
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 undef
202
202
;
203
203
%F16 = fmulhalfundef, undef
204
204
%F32 = fmulfloatundef, undef
@@ -278,7 +278,7 @@ define i32 @fdiv() {
278
278
; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %NXV2F64 = fdiv <vscale x 2 x double> undef, undef
279
279
; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %NXV4F64 = fdiv <vscale x 4 x double> undef, undef
280
280
; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %NXV8F64 = fdiv <vscale x 8 x double> undef, undef
281
-
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 undef
281
+
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 undef
282
282
;
283
283
%F16 = fdivhalfundef, undef
284
284
%F32 = fdivfloatundef, undef
@@ -358,7 +358,7 @@ define i32 @frem() {
358
358
; CHECK-NEXT: Cost Model: Invalid cost for instruction: %NXV2F64 = frem <vscale x 2 x double> undef, undef
359
359
; CHECK-NEXT: Cost Model: Invalid cost for instruction: %NXV4F64 = frem <vscale x 4 x double> undef, undef
360
360
; CHECK-NEXT: Cost Model: Invalid cost for instruction: %NXV8F64 = frem <vscale x 8 x double> undef, undef
361
-
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 undef
361
+
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 undef
362
362
;
363
363
%F16 = fremhalfundef, undef
364
364
%F32 = fremfloatundef, undef
@@ -438,7 +438,7 @@ define i32 @fneg() {
438
438
; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %NXV2F64 = fneg <vscale x 2 x double> undef
439
439
; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %NXV4F64 = fneg <vscale x 4 x double> undef
440
440
; CHECK-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %NXV8F64 = fneg <vscale x 8 x double> undef
441
-
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 undef
441
+
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 undef
442
442
;
443
443
%F16 = fneg halfundef
444
444
%F32 = fneg floatundef
@@ -518,7 +518,7 @@ define i32 @fcopysign() {
518
518
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %NXV2F64 = call <vscale x 2 x double> @llvm.copysign.nxv2f64(<vscale x 2 x double> undef, <vscale x 2 x double> undef)
519
519
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %NXV4F64 = call <vscale x 4 x double> @llvm.copysign.nxv4f64(<vscale x 4 x double> undef, <vscale x 4 x double> undef)
520
520
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %NXV8F64 = call <vscale x 8 x double> @llvm.copysign.nxv8f64(<vscale x 8 x double> undef, <vscale x 8 x double> undef)
521
-
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 undef
521
+
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 undef
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %NXV2F64 = call <vscale x 2 x double> @llvm.fma.nxv2f64(<vscale x 2 x double> undef, <vscale x 2 x double> undef, <vscale x 2 x double> undef)
599
599
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %NXV4F64 = call <vscale x 4 x double> @llvm.fma.nxv4f64(<vscale x 4 x double> undef, <vscale x 4 x double> undef, <vscale x 4 x double> undef)
600
600
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %NXV8F64 = call <vscale x 8 x double> @llvm.fma.nxv8f64(<vscale x 8 x double> undef, <vscale x 8 x double> undef, <vscale x 8 x double> undef)
601
-
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 undef
601
+
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 undef
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %28 = call <vscale x 4 x double> @llvm.fmuladd.nxv4f64(<vscale x 4 x double> undef, <vscale x 4 x double> undef, <vscale x 4 x double> undef)
676
676
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %29 = call <vscale x 8 x double> @llvm.fmuladd.nxv8f64(<vscale x 8 x double> undef, <vscale x 8 x double> undef, <vscale x 8 x double> undef)
677
677
; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %30 = call <vscale x 16 x double> @llvm.fmuladd.nxv16f64(<vscale x 16 x double> undef, <vscale x 16 x double> undef, <vscale x 16 x double> undef)
678
-
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret void
678
+
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
0 commit comments