xref: /llvm-project/llvm/test/CodeGen/SystemZ/int-const-01.ll (revision d24ab20e9b11d2076d8b9d5cd96f41a6b9c399fb)
19e3577ffSUlrich Weigand; Test loading of 32-bit constants.
29e3577ffSUlrich Weigand;
39e3577ffSUlrich Weigand; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
49e3577ffSUlrich Weigand
5a57e13b6SRichard Sandiforddeclare void @foo(i32, i32, i32, i32)
6a57e13b6SRichard Sandiford
79e3577ffSUlrich Weigand; Check 0.
89e3577ffSUlrich Weiganddefine i32 @f1() {
9*d24ab20eSStephen Lin; CHECK-LABEL: f1:
109e3577ffSUlrich Weigand; CHECK: lhi %r2, 0
119e3577ffSUlrich Weigand; CHECK: br %r14
129e3577ffSUlrich Weigand  ret i32 0
139e3577ffSUlrich Weigand}
149e3577ffSUlrich Weigand
159e3577ffSUlrich Weigand; Check the high end of the LHI range.
169e3577ffSUlrich Weiganddefine i32 @f2() {
17*d24ab20eSStephen Lin; CHECK-LABEL: f2:
189e3577ffSUlrich Weigand; CHECK: lhi %r2, 32767
199e3577ffSUlrich Weigand; CHECK: br %r14
209e3577ffSUlrich Weigand  ret i32 32767
219e3577ffSUlrich Weigand}
229e3577ffSUlrich Weigand
239e3577ffSUlrich Weigand; Check the next value up, which must use LLILL instead.
249e3577ffSUlrich Weiganddefine i32 @f3() {
25*d24ab20eSStephen Lin; CHECK-LABEL: f3:
269e3577ffSUlrich Weigand; CHECK: llill %r2, 32768
279e3577ffSUlrich Weigand; CHECK: br %r14
289e3577ffSUlrich Weigand  ret i32 32768
299e3577ffSUlrich Weigand}
309e3577ffSUlrich Weigand
319e3577ffSUlrich Weigand; Check the high end of the LLILL range.
329e3577ffSUlrich Weiganddefine i32 @f4() {
33*d24ab20eSStephen Lin; CHECK-LABEL: f4:
349e3577ffSUlrich Weigand; CHECK: llill %r2, 65535
359e3577ffSUlrich Weigand; CHECK: br %r14
369e3577ffSUlrich Weigand  ret i32 65535
379e3577ffSUlrich Weigand}
389e3577ffSUlrich Weigand
399e3577ffSUlrich Weigand; Check the first useful LLILH value, which is the next one up.
409e3577ffSUlrich Weiganddefine i32 @f5() {
41*d24ab20eSStephen Lin; CHECK-LABEL: f5:
429e3577ffSUlrich Weigand; CHECK: llilh %r2, 1
439e3577ffSUlrich Weigand; CHECK: br %r14
449e3577ffSUlrich Weigand  ret i32 65536
459e3577ffSUlrich Weigand}
469e3577ffSUlrich Weigand
479e3577ffSUlrich Weigand; Check the first useful IILF value, which is the next one up again.
489e3577ffSUlrich Weiganddefine i32 @f6() {
49*d24ab20eSStephen Lin; CHECK-LABEL: f6:
509e3577ffSUlrich Weigand; CHECK: iilf %r2, 65537
519e3577ffSUlrich Weigand; CHECK: br %r14
529e3577ffSUlrich Weigand  ret i32 65537
539e3577ffSUlrich Weigand}
549e3577ffSUlrich Weigand
559e3577ffSUlrich Weigand; Check the high end of the LLILH range.
569e3577ffSUlrich Weiganddefine i32 @f7() {
57*d24ab20eSStephen Lin; CHECK-LABEL: f7:
589e3577ffSUlrich Weigand; CHECK: llilh %r2, 65535
599e3577ffSUlrich Weigand; CHECK: br %r14
609e3577ffSUlrich Weigand  ret i32 -65536
619e3577ffSUlrich Weigand}
629e3577ffSUlrich Weigand
639e3577ffSUlrich Weigand; Check the next value up, which must use IILF.
649e3577ffSUlrich Weiganddefine i32 @f8() {
65*d24ab20eSStephen Lin; CHECK-LABEL: f8:
669e3577ffSUlrich Weigand; CHECK: iilf %r2, 4294901761
679e3577ffSUlrich Weigand; CHECK: br %r14
689e3577ffSUlrich Weigand  ret i32 -65535
699e3577ffSUlrich Weigand}
709e3577ffSUlrich Weigand
719e3577ffSUlrich Weigand; Check the highest useful IILF value, 0xffff7fff
729e3577ffSUlrich Weiganddefine i32 @f9() {
73*d24ab20eSStephen Lin; CHECK-LABEL: f9:
749e3577ffSUlrich Weigand; CHECK: iilf %r2, 4294934527
759e3577ffSUlrich Weigand; CHECK: br %r14
769e3577ffSUlrich Weigand  ret i32 -32769
779e3577ffSUlrich Weigand}
789e3577ffSUlrich Weigand
799e3577ffSUlrich Weigand; Check the next value up, which should use LHI.
809e3577ffSUlrich Weiganddefine i32 @f10() {
81*d24ab20eSStephen Lin; CHECK-LABEL: f10:
829e3577ffSUlrich Weigand; CHECK: lhi %r2, -32768
839e3577ffSUlrich Weigand; CHECK: br %r14
849e3577ffSUlrich Weigand  ret i32 -32768
859e3577ffSUlrich Weigand}
869e3577ffSUlrich Weigand
879e3577ffSUlrich Weigand; Check -1.
889e3577ffSUlrich Weiganddefine i32 @f11() {
89*d24ab20eSStephen Lin; CHECK-LABEL: f11:
909e3577ffSUlrich Weigand; CHECK: lhi %r2, -1
919e3577ffSUlrich Weigand; CHECK: br %r14
929e3577ffSUlrich Weigand  ret i32 -1
939e3577ffSUlrich Weigand}
94a57e13b6SRichard Sandiford
95a57e13b6SRichard Sandiford; Check that constant loads are rematerialized.
96a57e13b6SRichard Sandiforddefine i32 @f12() {
97*d24ab20eSStephen Lin; CHECK-LABEL: f12:
98a57e13b6SRichard Sandiford; CHECK-DAG: lhi %r2, 42
99a57e13b6SRichard Sandiford; CHECK-DAG: llill %r3, 32768
100a57e13b6SRichard Sandiford; CHECK-DAG: llilh %r4, 1
101a57e13b6SRichard Sandiford; CHECK-DAG: iilf %r5, 65537
102a57e13b6SRichard Sandiford; CHECK: brasl %r14, foo@PLT
103a57e13b6SRichard Sandiford; CHECK-DAG: lhi %r2, 42
104a57e13b6SRichard Sandiford; CHECK-DAG: llill %r3, 32768
105a57e13b6SRichard Sandiford; CHECK-DAG: llilh %r4, 1
106a57e13b6SRichard Sandiford; CHECK-DAG: iilf %r5, 65537
107a57e13b6SRichard Sandiford; CHECK: brasl %r14, foo@PLT
108a57e13b6SRichard Sandiford; CHECK: lhi %r2, 42
109a57e13b6SRichard Sandiford; CHECK: br %r14
110a57e13b6SRichard Sandiford  call void @foo(i32 42, i32 32768, i32 65536, i32 65537)
111a57e13b6SRichard Sandiford  call void @foo(i32 42, i32 32768, i32 65536, i32 65537)
112a57e13b6SRichard Sandiford  ret i32 42
113a57e13b6SRichard Sandiford}
114