
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.
183 lines
6.6 KiB
LLVM
183 lines
6.6 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 2
|
|
; RUN: opt < %s -mtriple=riscv64 -mattr=+f,+d -disable-output -passes="print<cost-model>" 2>&1 | FileCheck %s
|
|
|
|
define i8 @phi_i8(i1 %c) {
|
|
; CHECK-LABEL: 'phi_i8'
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: br i1 %c, label %a, label %b
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: br label %d
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: br label %d
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %x = phi i8 [ 16, %a ], [ 32, %b ]
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i8 %x
|
|
;
|
|
br i1 %c, label %a, label %b
|
|
a:
|
|
br label %d
|
|
b:
|
|
br label %d
|
|
d:
|
|
%x = phi i8 [16, %a], [32, %b]
|
|
ret i8 %x
|
|
}
|
|
|
|
define i16 @phi_i16_small(i1 %c) {
|
|
; CHECK-LABEL: 'phi_i16_small'
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: br i1 %c, label %a, label %b
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: br label %d
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: br label %d
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %x = phi i16 [ 1, %a ], [ 2, %b ]
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i16 %x
|
|
;
|
|
br i1 %c, label %a, label %b
|
|
a:
|
|
br label %d
|
|
b:
|
|
br label %d
|
|
d:
|
|
%x = phi i16 [1, %a], [2, %b]
|
|
ret i16 %x
|
|
}
|
|
|
|
define i16 @phi_i16_large(i1 %c) {
|
|
; CHECK-LABEL: 'phi_i16_large'
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: br i1 %c, label %a, label %b
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: br label %d
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: br label %d
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %x = phi i16 [ 42, %a ], [ -7616, %b ]
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i16 %x
|
|
;
|
|
br i1 %c, label %a, label %b
|
|
a:
|
|
br label %d
|
|
b:
|
|
br label %d
|
|
d:
|
|
%x = phi i16 [42, %a], [123456, %b]
|
|
ret i16 %x
|
|
}
|
|
|
|
define i32 @phi_i32_small(i1 %c) {
|
|
; CHECK-LABEL: 'phi_i32_small'
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: br i1 %c, label %a, label %b
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: br label %d
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: br label %d
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %x = phi i32 [ 1, %a ], [ 2, %b ]
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 %x
|
|
;
|
|
br i1 %c, label %a, label %b
|
|
a:
|
|
br label %d
|
|
b:
|
|
br label %d
|
|
d:
|
|
%x = phi i32 [1, %a], [2, %b]
|
|
ret i32 %x
|
|
}
|
|
|
|
define i32 @phi_i32_large(i1 %c) {
|
|
; CHECK-LABEL: 'phi_i32_large'
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: br i1 %c, label %a, label %b
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: br label %d
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: br label %d
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %x = phi i32 [ 42, %a ], [ 123456, %b ]
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 %x
|
|
;
|
|
br i1 %c, label %a, label %b
|
|
a:
|
|
br label %d
|
|
b:
|
|
br label %d
|
|
d:
|
|
%x = phi i32 [42, %a], [123456, %b]
|
|
ret i32 %x
|
|
}
|
|
|
|
define i64 @phi_i64_small(i1 %c) {
|
|
; CHECK-LABEL: 'phi_i64_small'
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: br i1 %c, label %a, label %b
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: br label %d
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: br label %d
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %x = phi i64 [ 1, %a ], [ 2, %b ]
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i64 %x
|
|
;
|
|
br i1 %c, label %a, label %b
|
|
a:
|
|
br label %d
|
|
b:
|
|
br label %d
|
|
d:
|
|
%x = phi i64 [1, %a], [2, %b]
|
|
ret i64 %x
|
|
}
|
|
|
|
define i64 @phi_i64_large(i1 %c) {
|
|
; CHECK-LABEL: 'phi_i64_large'
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: br i1 %c, label %a, label %b
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: br label %d
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: br label %d
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %x = phi i64 [ 42, %a ], [ 123456, %b ]
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i64 %x
|
|
;
|
|
br i1 %c, label %a, label %b
|
|
a:
|
|
br label %d
|
|
b:
|
|
br label %d
|
|
d:
|
|
%x = phi i64 [42, %a], [123456, %b]
|
|
ret i64 %x
|
|
}
|
|
|
|
define half @phi_f16(i1 %c) {
|
|
; CHECK-LABEL: 'phi_f16'
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: br i1 %c, label %a, label %b
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: br label %d
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: br label %d
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %x = phi half [ 0xHE3CE, %a ], [ 0xH5144, %b ]
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret half %x
|
|
;
|
|
br i1 %c, label %a, label %b
|
|
a:
|
|
br label %d
|
|
b:
|
|
br label %d
|
|
d:
|
|
%x = phi half [-999.0, %a], [42.125, %b]
|
|
ret half %x
|
|
}
|
|
|
|
define float @phi_f32(i1 %c) {
|
|
; CHECK-LABEL: 'phi_f32'
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: br i1 %c, label %a, label %b
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: br label %d
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: br label %d
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %x = phi float [ -9.990000e+02, %a ], [ 4.212500e+01, %b ]
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret float %x
|
|
;
|
|
br i1 %c, label %a, label %b
|
|
a:
|
|
br label %d
|
|
b:
|
|
br label %d
|
|
d:
|
|
%x = phi float [-999.0, %a], [42.125, %b]
|
|
ret float %x
|
|
}
|
|
|
|
define double @phi_f64(i1 %c) {
|
|
; CHECK-LABEL: 'phi_f64'
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: br i1 %c, label %a, label %b
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: br label %d
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: br label %d
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %x = phi double [ -9.990000e+02, %a ], [ 4.212500e+01, %b ]
|
|
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret double %x
|
|
;
|
|
br i1 %c, label %a, label %b
|
|
a:
|
|
br label %d
|
|
b:
|
|
br label %d
|
|
d:
|
|
%x = phi double [-999.0, %a], [42.125, %b]
|
|
ret double %x
|
|
}
|