brintos

brintos / llvm-project-archived public Read only

0
0
Text · 7.1 KiB · e444bbf Raw
172 lines · plain
1; RUN: opt < %s -passes="print<cost-model>" 2>&1 -disable-output -mtriple=systemz-unknown -mcpu=z13 | FileCheck %s --check-prefixes=CHECK,Z132; RUN: opt < %s -passes="print<cost-model>" 2>&1 -disable-output -mtriple=systemz-unknown -mcpu=z17 | FileCheck %s --check-prefixes=CHECK,Z173;4 5define i128 @fun1(i128 %val1, i128 %val2) {6; CHECK-LABEL: 'fun1'7; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   %cmp = icmp eq i128 %val1, %val28; Z13:   Cost Model: Found an estimated cost of 5 for instruction:   %v128 = sext i1 %cmp to i1289; Z17:   Cost Model: Found an estimated cost of 0 for instruction:   %v128 = sext i1 %cmp to i12810  %cmp = icmp eq i128 %val1, %val211  %v128 = sext i1 %cmp to i12812  ret i128 %v12813}14 15define i128 @fun2(i128 %val1, i128 %val2) {16; CHECK-LABEL: 'fun2'17; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   %cmp = icmp eq i128 %val1, %val218; CHECK: Cost Model: Found an estimated cost of 5 for instruction:   %v128 = zext i1 %cmp to i12819  %cmp = icmp eq i128 %val1, %val220  %v128 = zext i1 %cmp to i12821  ret i128 %v12822}23 24define i128 @fun3(i128 %val1, i128 %val2,25                  i128 %val3, i128 %val4) {26; CHECK-LABEL: 'fun3'27; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   %cmp = icmp eq i128 %val1, %val228; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   %add = add i128 %val3, %val429; Z13:   Cost Model: Found an estimated cost of 4 for instruction:   %sel = select i1 %cmp, i128 %val3, i128 %add30; Z17:   Cost Model: Found an estimated cost of 1 for instruction:   %sel = select i1 %cmp, i128 %val3, i128 %add31  %cmp = icmp eq i128 %val1, %val232  %add = add i128 %val3, %val433  %sel = select i1 %cmp, i128 %val3, i128 %add34  ret i128 %sel35}36 37define i64 @fun3_sel64(i128 %val1, i128 %val2,38                       i64 %val3, i64 %val4) {39; CHECK-LABEL: 'fun3_sel64'40; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   %cmp = icmp ugt i128 %val1, %val241; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   %add = add i64 %val3, %val442; Z13:   Cost Model: Found an estimated cost of 4 for instruction:   %sel = select i1 %cmp, i64 %val3, i64 %add43; Z17:   Cost Model: Found an estimated cost of 1 for instruction:   %sel = select i1 %cmp, i64 %val3, i64 %add44  %cmp = icmp ugt i128 %val1, %val245  %add = add i64 %val3, %val446  %sel = select i1 %cmp, i64 %val3, i64 %add47  ret i64 %sel48}49 50define i128 @fun3_cmp64(i64 %val1, i64 %val2,51                        i128 %val3, i128 %val4) {52; CHECK-LABEL: 'fun3_cmp64'53; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   %cmp = icmp slt i64 %val1, %val254; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   %add = add i128 %val3, %val455; CHECK: Cost Model: Found an estimated cost of 4 for instruction:   %sel = select i1 %cmp, i128 %val3, i128 %add56  %cmp = icmp slt i64 %val1, %val257  %add = add i128 %val3, %val458  %sel = select i1 %cmp, i128 %val3, i128 %add59  ret i128 %sel60}61 62define i128 @fun4(ptr %src) {63; CHECK-LABEL: 'fun4'64; CHECK: Cost Model: Found an estimated cost of 2 for instruction:   %res = sext i64 %v to i12865  %v = load i64, ptr %src, align 866  %res = sext i64 %v to i12867  ret i128 %res68}69 70define i128 @fun5(i64 %lhs, i64 %rhs) {71; CHECK-LABEL: 'fun5'72; CHECK: Cost Model: Found an estimated cost of 2 for instruction:   %res = sext i64 %v to i12873  %v = add i64 %lhs, %rhs74  %res = sext i64 %v to i12875  ret i128 %res76}77 78define i128 @fun6(ptr %src) {79; CHECK-LABEL: 'fun6'80; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   %res = zext i64 %v to i12881  %v = load i64, ptr %src, align 882  %res = zext i64 %v to i12883  ret i128 %res84}85 86define i128 @fun7(i64 %lhs, i64 %rhs) {87; CHECK-LABEL: 'fun7'88; CHECK: Cost Model: Found an estimated cost of 2 for instruction:   %res = zext i64 %v to i12889  %v = add i64 %lhs, %rhs90  %res = zext i64 %v to i12891  ret i128 %res92}93 94; Truncating store is free.95define void @fun8(i128 %lhs, i128 %rhs, ptr %dst) {96; CHECK-LABEL: 'fun8'97; CHECK: Cost Model: Found an estimated cost of 0 for instruction:   %t = trunc i128 %v to i6498  %v = add i128 %lhs, %rhs99  %t = trunc i128 %v to i64100  store i64 %t, ptr %dst, align 8101  ret void102}103 104; If there is a non-store user, an extraction is needed.105define i64 @fun9(i128 %lhs, i128 %rhs, ptr %dst) {106; CHECK-LABEL: 'fun9'107; CHECK: Cost Model: Found an estimated cost of 2 for instruction:   %t = trunc i128 %v to i64108  %v = add i128 %lhs, %rhs109  %t = trunc i128 %v to i64110  store i64 %t, ptr %dst, align 8111  ret i64 %t112}113 114; Truncation of load is free.115define i64 @fun10(ptr %src) {116; CHECK-LABEL: 'fun10'117; CHECK: Cost Model: Found an estimated cost of 0 for instruction:   %t = trunc i128 %v to i64118  %v = load i128, ptr %src, align 8119  %t = trunc i128 %v to i64120  ret i64 %t121}122 123; If the load has another user, the truncation becomes an extract.124define i64 @fun11(ptr %src, i128 %val2, ptr %dst) {125; CHECK-LABEL: 'fun11'126; CHECK: Cost Model: Found an estimated cost of 2 for instruction:   %t = trunc i128 %v to i64127  %v = load i128, ptr %src, align 8128  %t = trunc i128 %v to i64129  %a = add i128 %v, %val2130  store i128 %a, ptr %dst131  ret i64 %t132}133 134; Trunction with a GPR use typically requires an extraction.135define i64 @fun12(i128 %lhs, i128 %rhs) {136; CHECK-LABEL: 'fun12'137; CHECK: Cost Model: Found an estimated cost of 2 for instruction:   %t = trunc i128 %v to i64138  %v = add i128 %lhs, %rhs139  %t = trunc i128 %v to i64140  ret i64 %t141}142 143; Fp<->Int conversions require libcalls.144define void @fun13() {145; CHECK-LABEL: 'fun13'146; CHECK: Cost Model: Found an estimated cost of 30 for instruction:   %v0 = fptosi fp128 undef to i128147; CHECK: Cost Model: Found an estimated cost of 30 for instruction:   %v1 = fptosi double undef to i128148; CHECK: Cost Model: Found an estimated cost of 30 for instruction:   %v2 = fptosi float undef to i128149; CHECK: Cost Model: Found an estimated cost of 30 for instruction:   %v3 = fptoui fp128 undef to i128150; CHECK: Cost Model: Found an estimated cost of 30 for instruction:   %v4 = fptoui double undef to i128151; CHECK: Cost Model: Found an estimated cost of 30 for instruction:   %v5 = fptoui float undef to i128152; CHECK: Cost Model: Found an estimated cost of 30 for instruction:   %v6 = sitofp i128 undef to fp128153; CHECK: Cost Model: Found an estimated cost of 30 for instruction:   %v7 = sitofp i128 undef to double154; CHECK: Cost Model: Found an estimated cost of 30 for instruction:   %v8 = sitofp i128 undef to float155; CHECK: Cost Model: Found an estimated cost of 30 for instruction:   %v9 = uitofp i128 undef to fp128156; CHECK: Cost Model: Found an estimated cost of 30 for instruction:   %v10 = uitofp i128 undef to double157; CHECK: Cost Model: Found an estimated cost of 30 for instruction:   %v11 = uitofp i128 undef to float158  %v0 = fptosi fp128 undef to i128159  %v1 = fptosi double undef to i128160  %v2 = fptosi float undef to i128161  %v3 = fptoui fp128 undef to i128162  %v4 = fptoui double undef to i128163  %v5 = fptoui float undef to i128164  %v6 = sitofp i128 undef to fp128165  %v7 = sitofp i128 undef to double166  %v8 = sitofp i128 undef to float167  %v9 = uitofp i128 undef to fp128168  %v10 = uitofp i128 undef to double169  %v11 = uitofp i128 undef to float170  ret void171}172