The cost of vector instructions has always been high under AArch64, in order to add a high cost for inserts/extracts, shuffles and scalarization. This is a conservative approach to limit the scope of unusual SLP vectorization where the codegen ends up being quite poor, but has always been higher than the correct costs would be for any specific core. This relaxes that, reducing the vector insert/extract cost from 3 to 2. It is a generalization of D142359 to all AArch64 cpus. The ScalarizationOverhead is also overridden for integer vector at the same time, to remove the effect of lane 0 being considered free for integer vectors (something that should only be true for float when scalarizing). The lower insert/extract cost will reduce the cost of insert, extracts, shuffling and scalarization. The adjustments of ScalaizationOverhead will increase the cost on integer, especially for small vectors. The end result will be lower cost for float and long-integer types, some higher cost for some smaller vectors. This, along with the raw insert/extract cost being lower, will generally mean more vectorization from the Loop and SLP vectorizer. We may end up regretting this, as that vectorization is not always profitable. In all the benchmarking I have done this is generally an improvement in the overall performance, and I've attempted to address the places where it wasn't with other costmodel adjustments. Differential Revision: https://reviews.llvm.org/D155459
124 lines
9.4 KiB
LLVM
124 lines
9.4 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
|
|
; RUN: opt -passes="print<cost-model>" 2>&1 -disable-output -mtriple=aarch64-- < %s | FileCheck %s --check-prefix=CHECK-THROUGHPUT
|
|
; RUN: opt -passes="print<cost-model>" 2>&1 -disable-output -cost-kind=code-size -mtriple=aarch64-- < %s | FileCheck %s --check-prefix=CHECK-SIZE
|
|
|
|
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
|
|
|
|
define void @cmps() {
|
|
; CHECK-THROUGHPUT-LABEL: 'cmps'
|
|
; CHECK-THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %c8 = icmp slt i8 undef, undef
|
|
; CHECK-THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %c16 = icmp ult i16 undef, undef
|
|
; CHECK-THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %c32 = icmp sge i32 undef, undef
|
|
; CHECK-THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %c64 = icmp ne i64 undef, undef
|
|
; CHECK-THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %c128 = icmp ult i128 undef, undef
|
|
; CHECK-THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %cv16i8 = icmp slt <16 x i8> undef, undef
|
|
; CHECK-THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %cv8i16 = icmp ult <8 x i16> undef, undef
|
|
; CHECK-THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %cv4i32 = icmp sge <4 x i32> undef, undef
|
|
; CHECK-THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %cf16 = fcmp oge half undef, undef
|
|
; CHECK-THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %cf32 = fcmp ogt float undef, undef
|
|
; CHECK-THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %cf64 = fcmp ogt double undef, undef
|
|
; CHECK-THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 22 for instruction: %cfv816 = fcmp olt <8 x half> undef, undef
|
|
; CHECK-THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %cfv432 = fcmp oge <4 x float> undef, undef
|
|
; CHECK-THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %cfv264 = fcmp oge <2 x double> undef, undef
|
|
; CHECK-THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
|
|
;
|
|
; CHECK-SIZE-LABEL: 'cmps'
|
|
; CHECK-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %c8 = icmp slt i8 undef, undef
|
|
; CHECK-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %c16 = icmp ult i16 undef, undef
|
|
; CHECK-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %c32 = icmp sge i32 undef, undef
|
|
; CHECK-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %c64 = icmp ne i64 undef, undef
|
|
; CHECK-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %c128 = icmp ult i128 undef, undef
|
|
; CHECK-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %cv16i8 = icmp slt <16 x i8> undef, undef
|
|
; CHECK-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %cv8i16 = icmp ult <8 x i16> undef, undef
|
|
; CHECK-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %cv4i32 = icmp sge <4 x i32> undef, undef
|
|
; CHECK-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %cf16 = fcmp oge half undef, undef
|
|
; CHECK-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %cf32 = fcmp ogt float undef, undef
|
|
; CHECK-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %cf64 = fcmp ogt double undef, undef
|
|
; CHECK-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %cfv816 = fcmp olt <8 x half> undef, undef
|
|
; CHECK-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %cfv432 = fcmp oge <4 x float> undef, undef
|
|
; CHECK-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %cfv264 = fcmp oge <2 x double> undef, undef
|
|
; CHECK-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret void
|
|
;
|
|
%c8 = icmp slt i8 undef, undef
|
|
%c16 = icmp ult i16 undef, undef
|
|
%c32 = icmp sge i32 undef, undef
|
|
%c64 = icmp ne i64 undef, undef
|
|
%c128 = icmp ult i128 undef, undef
|
|
%cv16i8 = icmp slt <16 x i8> undef, undef
|
|
%cv8i16 = icmp ult <8 x i16> undef, undef
|
|
%cv4i32 = icmp sge <4 x i32> undef, undef
|
|
%cf16 = fcmp oge half undef, undef
|
|
%cf32 = fcmp ogt float undef, undef
|
|
%cf64 = fcmp ogt double undef, undef
|
|
%cfv816 = fcmp olt <8 x half> undef, undef
|
|
%cfv432 = fcmp oge <4 x float> undef, undef
|
|
%cfv264 = fcmp oge <2 x double> undef, undef
|
|
ret void
|
|
}
|
|
|
|
|
|
define void @andcmp() {
|
|
; CHECK-THROUGHPUT-LABEL: 'andcmp'
|
|
; CHECK-THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a8 = and i8 undef, undef
|
|
; CHECK-THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %c8 = icmp eq i8 %a8, 0
|
|
; CHECK-THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a16 = and i16 undef, undef
|
|
; CHECK-THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %c16 = icmp ne i16 %a16, 0
|
|
; CHECK-THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a32 = and i32 undef, undef
|
|
; CHECK-THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %c32 = icmp eq i32 %a32, 0
|
|
; CHECK-THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a64 = and i64 undef, undef
|
|
; CHECK-THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %c64 = icmp ne i64 %a64, 0
|
|
; CHECK-THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %a128 = and i128 undef, undef
|
|
; CHECK-THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %c128 = icmp eq i128 %a128, 0
|
|
; CHECK-THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %av16i8 = and <16 x i8> undef, undef
|
|
; CHECK-THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %cv16i8 = icmp ne <16 x i8> %av16i8, zeroinitializer
|
|
; CHECK-THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %av8i16 = and <8 x i16> undef, undef
|
|
; CHECK-THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %cv8i16 = icmp eq <8 x i16> %av8i16, zeroinitializer
|
|
; CHECK-THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %av4i32 = and <4 x i32> undef, undef
|
|
; CHECK-THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %cv4i32 = icmp ne <4 x i32> %av4i32, zeroinitializer
|
|
; CHECK-THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %c32not0 = icmp eq i32 %a32, 1
|
|
; CHECK-THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %c64sle = icmp sle i64 %a64, 0
|
|
; CHECK-THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
|
|
;
|
|
; CHECK-SIZE-LABEL: 'andcmp'
|
|
; CHECK-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a8 = and i8 undef, undef
|
|
; CHECK-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %c8 = icmp eq i8 %a8, 0
|
|
; CHECK-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a16 = and i16 undef, undef
|
|
; CHECK-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %c16 = icmp ne i16 %a16, 0
|
|
; CHECK-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a32 = and i32 undef, undef
|
|
; CHECK-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %c32 = icmp eq i32 %a32, 0
|
|
; CHECK-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a64 = and i64 undef, undef
|
|
; CHECK-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %c64 = icmp ne i64 %a64, 0
|
|
; CHECK-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a128 = and i128 undef, undef
|
|
; CHECK-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %c128 = icmp eq i128 %a128, 0
|
|
; CHECK-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %av16i8 = and <16 x i8> undef, undef
|
|
; CHECK-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %cv16i8 = icmp ne <16 x i8> %av16i8, zeroinitializer
|
|
; CHECK-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %av8i16 = and <8 x i16> undef, undef
|
|
; CHECK-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %cv8i16 = icmp eq <8 x i16> %av8i16, zeroinitializer
|
|
; CHECK-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %av4i32 = and <4 x i32> undef, undef
|
|
; CHECK-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %cv4i32 = icmp ne <4 x i32> %av4i32, zeroinitializer
|
|
; CHECK-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %c32not0 = icmp eq i32 %a32, 1
|
|
; CHECK-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %c64sle = icmp sle i64 %a64, 0
|
|
; CHECK-SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret void
|
|
;
|
|
%a8 = and i8 undef, undef
|
|
%c8 = icmp eq i8 %a8, 0
|
|
%a16 = and i16 undef, undef
|
|
%c16 = icmp ne i16 %a16, 0
|
|
%a32 = and i32 undef, undef
|
|
%c32 = icmp eq i32 %a32, 0
|
|
%a64 = and i64 undef, undef
|
|
%c64 = icmp ne i64 %a64, 0
|
|
%a128 = and i128 undef, undef
|
|
%c128 = icmp eq i128 %a128, zeroinitializer
|
|
%av16i8 = and <16 x i8> undef, undef
|
|
%cv16i8 = icmp ne <16 x i8> %av16i8, zeroinitializer
|
|
%av8i16 = and <8 x i16> undef, undef
|
|
%cv8i16 = icmp eq <8 x i16> %av8i16, zeroinitializer
|
|
%av4i32 = and <4 x i32> undef, undef
|
|
%cv4i32 = icmp ne <4 x i32> %av4i32, zeroinitializer
|
|
|
|
%c32not0 = icmp eq i32 %a32, 1
|
|
%c64sle = icmp sle i64 %a64, 0
|
|
ret void
|
|
}
|