160 changes: 107 additions & 53 deletions llvm/test/Analysis/CostModel/AArch64/cast.ll
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
; RUN: opt -cost-model -analyze -mtriple=aarch64-none-linux-gnueabi %s | FileCheck --check-prefixes=CHECK %s
; RUN: opt -cost-model -analyze -mtriple=aarch64-none-linux-gnueabi %s | FileCheck --check-prefixes=CHECK,CHECK-NOFP16 %s
; RUN: opt -cost-model -analyze -mtriple=aarch64-none-linux-gnueabi -mattr=+fullfp16 %s | FileCheck --check-prefixes=CHECK,CHECK-FP16 %s

define void @ext() {
; CHECK-LABEL: 'ext'
Expand Down Expand Up @@ -1022,58 +1023,111 @@ define void @extend_extract() {
declare void @use(i16, i16, i32, i32, i64, i64, i32, i32, i64, i64, i64, i64)

define void @fp16cast() {
; CHECK-LABEL: 'fp16cast'
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r30 = fptoui half undef to i1
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r31 = fptosi half undef to i1
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r32 = fptoui half undef to i8
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r33 = fptosi half undef to i8
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r34 = fptoui half undef to i16
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r35 = fptosi half undef to i16
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r36 = fptoui half undef to i32
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r37 = fptosi half undef to i32
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r38 = fptoui half undef to i64
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r39 = fptosi half undef to i64
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r90 = fptoui <2 x half> undef to <2 x i1>
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r91 = fptosi <2 x half> undef to <2 x i1>
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r92 = fptoui <2 x half> undef to <2 x i8>
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r93 = fptosi <2 x half> undef to <2 x i8>
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r94 = fptoui <2 x half> undef to <2 x i16>
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r95 = fptosi <2 x half> undef to <2 x i16>
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r96 = fptoui <2 x half> undef to <2 x i32>
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r97 = fptosi <2 x half> undef to <2 x i32>
; CHECK-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %r98 = fptoui <2 x half> undef to <2 x i64>
; CHECK-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %r99 = fptosi <2 x half> undef to <2 x i64>
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r110 = fptoui <4 x half> undef to <4 x i1>
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r111 = fptosi <4 x half> undef to <4 x i1>
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r112 = fptoui <4 x half> undef to <4 x i8>
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r113 = fptosi <4 x half> undef to <4 x i8>
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r114 = fptoui <4 x half> undef to <4 x i16>
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r115 = fptosi <4 x half> undef to <4 x i16>
; CHECK-NEXT: Cost Model: Found an estimated cost of 22 for instruction: %r116 = fptoui <4 x half> undef to <4 x i32>
; CHECK-NEXT: Cost Model: Found an estimated cost of 22 for instruction: %r117 = fptosi <4 x half> undef to <4 x i32>
; CHECK-NEXT: Cost Model: Found an estimated cost of 17 for instruction: %r118 = fptoui <4 x half> undef to <4 x i64>
; CHECK-NEXT: Cost Model: Found an estimated cost of 17 for instruction: %r119 = fptosi <4 x half> undef to <4 x i64>
; CHECK-NEXT: Cost Model: Found an estimated cost of 50 for instruction: %r130 = fptoui <8 x half> undef to <8 x i1>
; CHECK-NEXT: Cost Model: Found an estimated cost of 50 for instruction: %r131 = fptosi <8 x half> undef to <8 x i1>
; CHECK-NEXT: Cost Model: Found an estimated cost of 50 for instruction: %r132 = fptoui <8 x half> undef to <8 x i8>
; CHECK-NEXT: Cost Model: Found an estimated cost of 50 for instruction: %r133 = fptosi <8 x half> undef to <8 x i8>
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r134 = fptoui <8 x half> undef to <8 x i16>
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r135 = fptosi <8 x half> undef to <8 x i16>
; CHECK-NEXT: Cost Model: Found an estimated cost of 45 for instruction: %r136 = fptoui <8 x half> undef to <8 x i32>
; CHECK-NEXT: Cost Model: Found an estimated cost of 45 for instruction: %r137 = fptosi <8 x half> undef to <8 x i32>
; CHECK-NEXT: Cost Model: Found an estimated cost of 35 for instruction: %r138 = fptoui <8 x half> undef to <8 x i64>
; CHECK-NEXT: Cost Model: Found an estimated cost of 35 for instruction: %r139 = fptosi <8 x half> undef to <8 x i64>
; CHECK-NEXT: Cost Model: Found an estimated cost of 101 for instruction: %r150 = fptoui <16 x half> undef to <16 x i1>
; CHECK-NEXT: Cost Model: Found an estimated cost of 101 for instruction: %r151 = fptosi <16 x half> undef to <16 x i1>
; CHECK-NEXT: Cost Model: Found an estimated cost of 101 for instruction: %r152 = fptoui <16 x half> undef to <16 x i8>
; CHECK-NEXT: Cost Model: Found an estimated cost of 101 for instruction: %r153 = fptosi <16 x half> undef to <16 x i8>
; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %r154 = fptoui <16 x half> undef to <16 x i16>
; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %r155 = fptosi <16 x half> undef to <16 x i16>
; CHECK-NEXT: Cost Model: Found an estimated cost of 90 for instruction: %r156 = fptoui <16 x half> undef to <16 x i32>
; CHECK-NEXT: Cost Model: Found an estimated cost of 90 for instruction: %r157 = fptosi <16 x half> undef to <16 x i32>
; CHECK-NEXT: Cost Model: Found an estimated cost of 70 for instruction: %r158 = fptoui <16 x half> undef to <16 x i64>
; CHECK-NEXT: Cost Model: Found an estimated cost of 70 for instruction: %r159 = fptosi <16 x half> undef to <16 x i64>
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
; CHECK-NOFP16-LABEL: 'fp16cast'
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r30 = fptoui half undef to i1
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r31 = fptosi half undef to i1
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r32 = fptoui half undef to i8
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r33 = fptosi half undef to i8
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r34 = fptoui half undef to i16
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r35 = fptosi half undef to i16
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r36 = fptoui half undef to i32
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r37 = fptosi half undef to i32
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r38 = fptoui half undef to i64
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r39 = fptosi half undef to i64
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r90 = fptoui <2 x half> undef to <2 x i1>
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r91 = fptosi <2 x half> undef to <2 x i1>
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r92 = fptoui <2 x half> undef to <2 x i8>
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r93 = fptosi <2 x half> undef to <2 x i8>
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r94 = fptoui <2 x half> undef to <2 x i16>
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r95 = fptosi <2 x half> undef to <2 x i16>
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r96 = fptoui <2 x half> undef to <2 x i32>
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r97 = fptosi <2 x half> undef to <2 x i32>
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %r98 = fptoui <2 x half> undef to <2 x i64>
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %r99 = fptosi <2 x half> undef to <2 x i64>
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r110 = fptoui <4 x half> undef to <4 x i1>
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r111 = fptosi <4 x half> undef to <4 x i1>
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r112 = fptoui <4 x half> undef to <4 x i8>
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r113 = fptosi <4 x half> undef to <4 x i8>
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r114 = fptoui <4 x half> undef to <4 x i16>
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r115 = fptosi <4 x half> undef to <4 x i16>
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 22 for instruction: %r116 = fptoui <4 x half> undef to <4 x i32>
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 22 for instruction: %r117 = fptosi <4 x half> undef to <4 x i32>
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 17 for instruction: %r118 = fptoui <4 x half> undef to <4 x i64>
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 17 for instruction: %r119 = fptosi <4 x half> undef to <4 x i64>
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 50 for instruction: %r130 = fptoui <8 x half> undef to <8 x i1>
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 50 for instruction: %r131 = fptosi <8 x half> undef to <8 x i1>
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 50 for instruction: %r132 = fptoui <8 x half> undef to <8 x i8>
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 50 for instruction: %r133 = fptosi <8 x half> undef to <8 x i8>
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r134 = fptoui <8 x half> undef to <8 x i16>
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r135 = fptosi <8 x half> undef to <8 x i16>
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 45 for instruction: %r136 = fptoui <8 x half> undef to <8 x i32>
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 45 for instruction: %r137 = fptosi <8 x half> undef to <8 x i32>
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 35 for instruction: %r138 = fptoui <8 x half> undef to <8 x i64>
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 35 for instruction: %r139 = fptosi <8 x half> undef to <8 x i64>
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 101 for instruction: %r150 = fptoui <16 x half> undef to <16 x i1>
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 101 for instruction: %r151 = fptosi <16 x half> undef to <16 x i1>
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 101 for instruction: %r152 = fptoui <16 x half> undef to <16 x i8>
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 101 for instruction: %r153 = fptosi <16 x half> undef to <16 x i8>
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %r154 = fptoui <16 x half> undef to <16 x i16>
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %r155 = fptosi <16 x half> undef to <16 x i16>
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 90 for instruction: %r156 = fptoui <16 x half> undef to <16 x i32>
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 90 for instruction: %r157 = fptosi <16 x half> undef to <16 x i32>
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 70 for instruction: %r158 = fptoui <16 x half> undef to <16 x i64>
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 70 for instruction: %r159 = fptosi <16 x half> undef to <16 x i64>
; CHECK-NOFP16-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
;
; CHECK-FP16-LABEL: 'fp16cast'
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r30 = fptoui half undef to i1
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r31 = fptosi half undef to i1
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r32 = fptoui half undef to i8
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r33 = fptosi half undef to i8
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r34 = fptoui half undef to i16
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r35 = fptosi half undef to i16
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r36 = fptoui half undef to i32
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r37 = fptosi half undef to i32
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r38 = fptoui half undef to i64
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r39 = fptosi half undef to i64
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r90 = fptoui <2 x half> undef to <2 x i1>
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r91 = fptosi <2 x half> undef to <2 x i1>
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r92 = fptoui <2 x half> undef to <2 x i8>
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r93 = fptosi <2 x half> undef to <2 x i8>
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r94 = fptoui <2 x half> undef to <2 x i16>
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r95 = fptosi <2 x half> undef to <2 x i16>
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r96 = fptoui <2 x half> undef to <2 x i32>
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r97 = fptosi <2 x half> undef to <2 x i32>
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %r98 = fptoui <2 x half> undef to <2 x i64>
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %r99 = fptosi <2 x half> undef to <2 x i64>
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r110 = fptoui <4 x half> undef to <4 x i1>
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r111 = fptosi <4 x half> undef to <4 x i1>
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r112 = fptoui <4 x half> undef to <4 x i8>
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r113 = fptosi <4 x half> undef to <4 x i8>
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r114 = fptoui <4 x half> undef to <4 x i16>
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r115 = fptosi <4 x half> undef to <4 x i16>
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %r116 = fptoui <4 x half> undef to <4 x i32>
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %r117 = fptosi <4 x half> undef to <4 x i32>
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 17 for instruction: %r118 = fptoui <4 x half> undef to <4 x i64>
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 17 for instruction: %r119 = fptosi <4 x half> undef to <4 x i64>
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 50 for instruction: %r130 = fptoui <8 x half> undef to <8 x i1>
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 50 for instruction: %r131 = fptosi <8 x half> undef to <8 x i1>
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %r132 = fptoui <8 x half> undef to <8 x i8>
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %r133 = fptosi <8 x half> undef to <8 x i8>
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r134 = fptoui <8 x half> undef to <8 x i16>
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r135 = fptosi <8 x half> undef to <8 x i16>
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %r136 = fptoui <8 x half> undef to <8 x i32>
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %r137 = fptosi <8 x half> undef to <8 x i32>
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 35 for instruction: %r138 = fptoui <8 x half> undef to <8 x i64>
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 35 for instruction: %r139 = fptosi <8 x half> undef to <8 x i64>
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 101 for instruction: %r150 = fptoui <16 x half> undef to <16 x i1>
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 101 for instruction: %r151 = fptosi <16 x half> undef to <16 x i1>
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %r152 = fptoui <16 x half> undef to <16 x i8>
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %r153 = fptosi <16 x half> undef to <16 x i8>
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %r154 = fptoui <16 x half> undef to <16 x i16>
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %r155 = fptosi <16 x half> undef to <16 x i16>
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %r156 = fptoui <16 x half> undef to <16 x i32>
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %r157 = fptosi <16 x half> undef to <16 x i32>
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 70 for instruction: %r158 = fptoui <16 x half> undef to <16 x i64>
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 70 for instruction: %r159 = fptosi <16 x half> undef to <16 x i64>
; CHECK-FP16-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
;
%r30 = fptoui half undef to i1
%r31 = fptosi half undef to i1
Expand Down