xref: /llvm-project/llvm/test/CodeGen/SystemZ/int-add-06.ll (revision d24ab20e9b11d2076d8b9d5cd96f41a6b9c399fb)
19e3577ffSUlrich Weigand; Test 32-bit addition in which the second operand is constant.
29e3577ffSUlrich Weigand;
39e3577ffSUlrich Weigand; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
49e3577ffSUlrich Weigand
59e3577ffSUlrich Weigand; Check additions of 1.
69e3577ffSUlrich Weiganddefine i32 @f1(i32 %a) {
7*d24ab20eSStephen Lin; CHECK-LABEL: f1:
89e3577ffSUlrich Weigand; CHECK: ahi %r2, 1
99e3577ffSUlrich Weigand; CHECK: br %r14
109e3577ffSUlrich Weigand  %add = add i32 %a, 1
119e3577ffSUlrich Weigand  ret i32 %add
129e3577ffSUlrich Weigand}
139e3577ffSUlrich Weigand
149e3577ffSUlrich Weigand; Check the high end of the AHI range.
159e3577ffSUlrich Weiganddefine i32 @f2(i32 %a) {
16*d24ab20eSStephen Lin; CHECK-LABEL: f2:
179e3577ffSUlrich Weigand; CHECK: ahi %r2, 32767
189e3577ffSUlrich Weigand; CHECK: br %r14
199e3577ffSUlrich Weigand  %add = add i32 %a, 32767
209e3577ffSUlrich Weigand  ret i32 %add
219e3577ffSUlrich Weigand}
229e3577ffSUlrich Weigand
239e3577ffSUlrich Weigand; Check the next value up, which must use AFI instead.
249e3577ffSUlrich Weiganddefine i32 @f3(i32 %a) {
25*d24ab20eSStephen Lin; CHECK-LABEL: f3:
269e3577ffSUlrich Weigand; CHECK: afi %r2, 32768
279e3577ffSUlrich Weigand; CHECK: br %r14
289e3577ffSUlrich Weigand  %add = add i32 %a, 32768
299e3577ffSUlrich Weigand  ret i32 %add
309e3577ffSUlrich Weigand}
319e3577ffSUlrich Weigand
329e3577ffSUlrich Weigand; Check the high end of the signed 32-bit range.
339e3577ffSUlrich Weiganddefine i32 @f4(i32 %a) {
34*d24ab20eSStephen Lin; CHECK-LABEL: f4:
359e3577ffSUlrich Weigand; CHECK: afi %r2, 2147483647
369e3577ffSUlrich Weigand; CHECK: br %r14
379e3577ffSUlrich Weigand  %add = add i32 %a, 2147483647
389e3577ffSUlrich Weigand  ret i32 %add
399e3577ffSUlrich Weigand}
409e3577ffSUlrich Weigand
419e3577ffSUlrich Weigand; Check the next value up, which is treated as a negative value.
429e3577ffSUlrich Weiganddefine i32 @f5(i32 %a) {
43*d24ab20eSStephen Lin; CHECK-LABEL: f5:
449e3577ffSUlrich Weigand; CHECK: afi %r2, -2147483648
459e3577ffSUlrich Weigand; CHECK: br %r14
469e3577ffSUlrich Weigand  %add = add i32 %a, 2147483648
479e3577ffSUlrich Weigand  ret i32 %add
489e3577ffSUlrich Weigand}
499e3577ffSUlrich Weigand
509e3577ffSUlrich Weigand; Check the high end of the negative AHI range.
519e3577ffSUlrich Weiganddefine i32 @f6(i32 %a) {
52*d24ab20eSStephen Lin; CHECK-LABEL: f6:
539e3577ffSUlrich Weigand; CHECK: ahi %r2, -1
549e3577ffSUlrich Weigand; CHECK: br %r14
559e3577ffSUlrich Weigand  %add = add i32 %a, -1
569e3577ffSUlrich Weigand  ret i32 %add
579e3577ffSUlrich Weigand}
589e3577ffSUlrich Weigand
599e3577ffSUlrich Weigand; Check the low end of the AHI range.
609e3577ffSUlrich Weiganddefine i32 @f7(i32 %a) {
61*d24ab20eSStephen Lin; CHECK-LABEL: f7:
629e3577ffSUlrich Weigand; CHECK: ahi %r2, -32768
639e3577ffSUlrich Weigand; CHECK: br %r14
649e3577ffSUlrich Weigand  %add = add i32 %a, -32768
659e3577ffSUlrich Weigand  ret i32 %add
669e3577ffSUlrich Weigand}
679e3577ffSUlrich Weigand
689e3577ffSUlrich Weigand; Check the next value down, which must use AFI instead.
699e3577ffSUlrich Weiganddefine i32 @f8(i32 %a) {
70*d24ab20eSStephen Lin; CHECK-LABEL: f8:
719e3577ffSUlrich Weigand; CHECK: afi %r2, -32769
729e3577ffSUlrich Weigand; CHECK: br %r14
739e3577ffSUlrich Weigand  %add = add i32 %a, -32769
749e3577ffSUlrich Weigand  ret i32 %add
759e3577ffSUlrich Weigand}
769e3577ffSUlrich Weigand
779e3577ffSUlrich Weigand; Check the low end of the signed 32-bit range.
789e3577ffSUlrich Weiganddefine i32 @f9(i32 %a) {
79*d24ab20eSStephen Lin; CHECK-LABEL: f9:
809e3577ffSUlrich Weigand; CHECK: afi %r2, -2147483648
819e3577ffSUlrich Weigand; CHECK: br %r14
829e3577ffSUlrich Weigand  %add = add i32 %a, -2147483648
839e3577ffSUlrich Weigand  ret i32 %add
849e3577ffSUlrich Weigand}
859e3577ffSUlrich Weigand
869e3577ffSUlrich Weigand; Check the next value down, which is treated as a positive value.
879e3577ffSUlrich Weiganddefine i32 @f10(i32 %a) {
88*d24ab20eSStephen Lin; CHECK-LABEL: f10:
899e3577ffSUlrich Weigand; CHECK: afi %r2, 2147483647
909e3577ffSUlrich Weigand; CHECK: br %r14
919e3577ffSUlrich Weigand  %add = add i32 %a, -2147483649
929e3577ffSUlrich Weigand  ret i32 %add
939e3577ffSUlrich Weigand}
94