xref: /llvm-project/llvm/test/Analysis/CostModel/SystemZ/load-to-trunc.ll (revision e39f6c1844fab59c638d8059a6cf139adb42279a)
14ff4e7eaSAndrew Litteken; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
24ff4e7eaSAndrew Litteken; Check memory cost model action for a load of an unusually sized integer
34ff4e7eaSAndrew Litteken; follow by and a trunc to a register sized integer gives a cost of 1 rather
44ff4e7eaSAndrew Litteken; than the expanded cost if it is not.  This target does not currently perform
54ff4e7eaSAndrew Litteken; the expansion in the cost modelling.
64178e334SSimon Pilgrim; RUN: opt -passes="print<cost-model>" -cost-kind=code-size 2>&1 -disable-output -mtriple=systemz-unknown < %s | FileCheck %s --check-prefix=CHECK
74ff4e7eaSAndrew Litteken
84ff4e7eaSAndrew Litteken; Check that cost is 1 for unusual load to register sized load.
968c50b11SNikita Popovdefine i32 @loadUnusualIntegerWithTrunc(ptr %ptr) {
104ff4e7eaSAndrew Litteken; CHECK-LABEL: 'loadUnusualIntegerWithTrunc'
11*e39f6c18SAlex Richardson; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %out = load i128, ptr %ptr, align 8
124ff4e7eaSAndrew Litteken; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %trunc = trunc i128 %out to i32
134ff4e7eaSAndrew Litteken; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: ret i32 %trunc
144ff4e7eaSAndrew Litteken;
1568c50b11SNikita Popov  %out = load i128, ptr %ptr
164ff4e7eaSAndrew Litteken  %trunc = trunc i128 %out to i32
174ff4e7eaSAndrew Litteken  ret i32 %trunc
184ff4e7eaSAndrew Litteken}
194ff4e7eaSAndrew Litteken
2068c50b11SNikita Popovdefine i128 @loadUnusualInteger(ptr %ptr) {
214ff4e7eaSAndrew Litteken; CHECK-LABEL: 'loadUnusualInteger'
22*e39f6c18SAlex Richardson; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %out = load i128, ptr %ptr, align 8
234ff4e7eaSAndrew Litteken; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: ret i128 %out
244ff4e7eaSAndrew Litteken;
2568c50b11SNikita Popov  %out = load i128, ptr %ptr
264ff4e7eaSAndrew Litteken  ret i128 %out
274ff4e7eaSAndrew Litteken}
28