xref: /llvm-project/llvm/test/Analysis/CostModel/SystemZ/cmp-mem.ll (revision 68c50b111d74afb9489cf97770fa917d0a1c7f77)
1; RUN: opt < %s -passes="print<cost-model>" 2>&1 -disable-output -mtriple=systemz-unknown -mcpu=z13 | FileCheck %s
2;
3; Test costs for i8 and i16 comparisons against memory with a small immediate.
4
5define i32 @fun0(ptr %Src, ptr %Dst, i8 %Val) {
6; CHECK: function 'fun0'
7; CHECK: Cost Model: Found an estimated cost of 0 for instruction:   %Ld = load i8, ptr %Src
8; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   %Cmp = icmp eq i8 %Ld, 123
9; CHECK: Cost Model: Found an estimated cost of 2 for instruction:   %Ret = zext i1 %Cmp to i32
10; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   ret i32 %Ret
11  %Ld = load i8, ptr %Src
12  %Cmp = icmp eq i8 %Ld, 123
13  %Ret = zext i1 %Cmp to i32
14  ret i32 %Ret
15}
16
17define i32 @fun1(ptr %Src, ptr %Dst, i16 %Val) {
18; CHECK: function 'fun1'
19; CHECK: Cost Model: Found an estimated cost of 0 for instruction:   %Ld = load i16, ptr %Src
20; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   %Cmp = icmp eq i16
21; CHECK: Cost Model: Found an estimated cost of 2 for instruction:   %Ret = zext i1 %Cmp to i32
22; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   ret i32 %Ret
23  %Ld = load i16, ptr %Src
24  %Cmp = icmp eq i16 %Ld, 1234
25  %Ret = zext i1 %Cmp to i32
26  ret i32 %Ret
27}
28