xref: /llvm-project/llvm/test/Analysis/CostModel/X86/load-to-trunc.ll (revision e39f6c1844fab59c638d8059a6cf139adb42279a)
1; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
2; Check memory cost model action for a load of an unusually sized integer
3; follow by and a trunc to a register sized integer gives a cost of 1 rather
4; than the expanded cost.  Currently the x86 code size cost model does not use
5; the expanded cost and only assigns a cost of 1 to each load.
6
7; RUN: opt -passes="print<cost-model>" -cost-kind=code-size 2>&1 -disable-output -mtriple=x86_64--linux-gnu < %s | FileCheck %s --check-prefix=CHECK
8
9; Check that cost is 1 for unusual load to register sized load.
10define i32 @loadUnusualIntegerWithTrunc(ptr %ptr) {
11; CHECK-LABEL: 'loadUnusualIntegerWithTrunc'
12; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %out = load i128, ptr %ptr, align 16
13; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %trunc = trunc i128 %out to i32
14; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: ret i32 %trunc
15;
16  %out = load i128, ptr %ptr
17  %trunc = trunc i128 %out to i32
18  ret i32 %trunc
19}
20
21define i128 @loadUnusualInteger(ptr %ptr) {
22; CHECK-LABEL: 'loadUnusualInteger'
23; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %out = load i128, ptr %ptr, align 16
24; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: ret i128 %out
25;
26  %out = load i128, ptr %ptr
27  ret i128 %out
28}
29