1 ; RUN: opt < %s -passes="print<cost-model>" 2>&1 -disable-output -mtriple=systemz-unknown -mcpu=z13 | FileCheck %s
4 define i128 @fun1(i128 %val1, i128 %val2) {
6 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %cmp = icmp eq i128 %val1, %val2
7 ; CHECK: Cost Model: Found an estimated cost of 5 for instruction: %v128 = sext i1 %cmp to i128
8 %cmp = icmp eq i128 %val1, %val2
9 %v128 = sext i1 %cmp to i128
13 define i128 @fun2(i128 %val1, i128 %val2) {
15 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %cmp = icmp eq i128 %val1, %val2
16 ; CHECK: Cost Model: Found an estimated cost of 5 for instruction: %v128 = zext i1 %cmp to i128
17 %cmp = icmp eq i128 %val1, %val2
18 %v128 = zext i1 %cmp to i128
22 define i128 @fun3(i128 %val1, i128 %val2,
23 i128 %val3, i128 %val4) {
25 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %cmp = icmp eq i128 %val1, %val2
26 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %add = add i128 %val3, %val4
27 ; CHECK: Cost Model: Found an estimated cost of 4 for instruction: %sel = select i1 %cmp, i128 %val3, i128 %add
28 %cmp = icmp eq i128 %val1, %val2
29 %add = add i128 %val3, %val4
30 %sel = select i1 %cmp, i128 %val3, i128 %add
34 define i128 @fun4(ptr %src) {
36 ; CHECK: Cost Model: Found an estimated cost of 2 for instruction: %res = sext i64 %v to i128
37 %v = load i64, ptr %src, align 8
38 %res = sext i64 %v to i128
42 define i128 @fun5(i64 %lhs, i64 %rhs) {
44 ; CHECK: Cost Model: Found an estimated cost of 2 for instruction: %res = sext i64 %v to i128
45 %v = add i64 %lhs, %rhs
46 %res = sext i64 %v to i128
50 define i128 @fun6(ptr %src) {
52 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %res = zext i64 %v to i128
53 %v = load i64, ptr %src, align 8
54 %res = zext i64 %v to i128
58 define i128 @fun7(i64 %lhs, i64 %rhs) {
60 ; CHECK: Cost Model: Found an estimated cost of 2 for instruction: %res = zext i64 %v to i128
61 %v = add i64 %lhs, %rhs
62 %res = zext i64 %v to i128
66 ; Truncating store is free.
67 define void @fun8(i128 %lhs, i128 %rhs, ptr %dst) {
69 ; CHECK: Cost Model: Found an estimated cost of 0 for instruction: %t = trunc i128 %v to i64
70 %v = add i128 %lhs, %rhs
71 %t = trunc i128 %v to i64
72 store i64 %t, ptr %dst, align 8
76 ; If there is a non-store user, an extraction is needed.
77 define i64 @fun9(i128 %lhs, i128 %rhs, ptr %dst) {
79 ; CHECK: Cost Model: Found an estimated cost of 2 for instruction: %t = trunc i128 %v to i64
80 %v = add i128 %lhs, %rhs
81 %t = trunc i128 %v to i64
82 store i64 %t, ptr %dst, align 8
86 ; Truncation of load is free.
87 define i64 @fun10(ptr %src) {
88 ; CHECK-LABEL: 'fun10'
89 ; CHECK: Cost Model: Found an estimated cost of 0 for instruction: %t = trunc i128 %v to i64
90 %v = load i128, ptr %src, align 8
91 %t = trunc i128 %v to i64
95 ; If the load has another user, the truncation becomes an extract.
96 define i64 @fun11(ptr %src, i128 %val2, ptr %dst) {
97 ; CHECK-LABEL: 'fun11'
98 ; CHECK: Cost Model: Found an estimated cost of 2 for instruction: %t = trunc i128 %v to i64
99 %v = load i128, ptr %src, align 8
100 %t = trunc i128 %v to i64
101 %a = add i128 %v, %val2
102 store i128 %a, ptr %dst
106 ; Trunction with a GPR use typically requires an extraction.
107 define i64 @fun12(i128 %lhs, i128 %rhs) {
108 ; CHECK-LABEL: 'fun12'
109 ; CHECK: Cost Model: Found an estimated cost of 2 for instruction: %t = trunc i128 %v to i64
110 %v = add i128 %lhs, %rhs
111 %t = trunc i128 %v to i64
115 ; Fp<->Int conversions require libcalls.
116 define void @fun13() {
117 ; CHECK-LABEL: 'fun13'
118 ; CHECK: Cost Model: Found an estimated cost of 30 for instruction: %v0 = fptosi fp128 undef to i128
119 ; CHECK: Cost Model: Found an estimated cost of 30 for instruction: %v1 = fptosi double undef to i128
120 ; CHECK: Cost Model: Found an estimated cost of 30 for instruction: %v2 = fptosi float undef to i128
121 ; CHECK: Cost Model: Found an estimated cost of 30 for instruction: %v3 = fptoui fp128 undef to i128
122 ; CHECK: Cost Model: Found an estimated cost of 30 for instruction: %v4 = fptoui double undef to i128
123 ; CHECK: Cost Model: Found an estimated cost of 30 for instruction: %v5 = fptoui float undef to i128
124 ; CHECK: Cost Model: Found an estimated cost of 30 for instruction: %v6 = sitofp i128 undef to fp128
125 ; CHECK: Cost Model: Found an estimated cost of 30 for instruction: %v7 = sitofp i128 undef to double
126 ; CHECK: Cost Model: Found an estimated cost of 30 for instruction: %v8 = sitofp i128 undef to float
127 ; CHECK: Cost Model: Found an estimated cost of 30 for instruction: %v9 = uitofp i128 undef to fp128
128 ; CHECK: Cost Model: Found an estimated cost of 30 for instruction: %v10 = uitofp i128 undef to double
129 ; CHECK: Cost Model: Found an estimated cost of 30 for instruction: %v11 = uitofp i128 undef to float
130 %v0 = fptosi fp128 undef to i128
131 %v1 = fptosi double undef to i128
132 %v2 = fptosi float undef to i128
133 %v3 = fptoui fp128 undef to i128
134 %v4 = fptoui double undef to i128
135 %v5 = fptoui float undef to i128
136 %v6 = sitofp i128 undef to fp128
137 %v7 = sitofp i128 undef to double
138 %v8 = sitofp i128 undef to float
139 %v9 = uitofp i128 undef to fp128
140 %v10 = uitofp i128 undef to double
141 %v11 = uitofp i128 undef to float