Index: llvm/test/CodeGen/ARM/add-sub-imm.ll =================================================================== --- /dev/null +++ llvm/test/CodeGen/ARM/add-sub-imm.ll @@ -0,0 +1,74 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc -mtriple=arm-eabi %s -o - | FileCheck %s --check-prefix=CHECK + +; Check how immediates are handled in add/sub. + +define i32 @sub0(i32 %0) { +; CHECK-LABEL: sub0: +; CHECK: @ %bb.0: +; CHECK-NEXT: sub r0, r0, #23 +; CHECK-NEXT: mov pc, lr + %2 = sub i32 %0, 23 + ret i32 %2 +} + +define i32 @sub1(i32 %0) { +; CHECK-LABEL: sub1: +; CHECK: @ %bb.0: +; CHECK-NEXT: ldr r1, .LCPI1_0 +; CHECK-NEXT: add r0, r0, r1 +; CHECK-NEXT: mov pc, lr +; CHECK-NEXT: .p2align 2 +; CHECK-NEXT: @ %bb.1: +; CHECK-NEXT: .LCPI1_0: +; CHECK-NEXT: .long 4294836225 @ 0xfffe0001 + %2 = sub i32 %0, 131071 + ret i32 %2 +} + +define i32 @sub2(i32 %0) { +; CHECK-LABEL: sub2: +; CHECK: @ %bb.0: +; CHECK-NEXT: ldr r1, .LCPI2_0 +; CHECK-NEXT: add r0, r0, r1 +; CHECK-NEXT: mov pc, lr +; CHECK-NEXT: .p2align 2 +; CHECK-NEXT: @ %bb.1: +; CHECK-NEXT: .LCPI2_0: +; CHECK-NEXT: .long 4292664576 @ 0xffdcdd00 + %2 = sub i32 %0, 2302720 + ret i32 %2 +} + +define i32 @add0(i32 %0) { +; CHECK-LABEL: add0: +; CHECK: @ %bb.0: +; CHECK-NEXT: add r0, r0, #23 +; CHECK-NEXT: mov pc, lr + %2 = add i32 %0, 23 + ret i32 %2 +} + +define i32 @add1(i32 %0) { +; CHECK-LABEL: add1: +; CHECK: @ %bb.0: +; CHECK-NEXT: ldr r1, .LCPI4_0 +; CHECK-NEXT: add r0, r0, r1 +; CHECK-NEXT: mov pc, lr +; CHECK-NEXT: .p2align 2 +; CHECK-NEXT: @ %bb.1: +; CHECK-NEXT: .LCPI4_0: +; CHECK-NEXT: .long 131071 @ 0x1ffff + %2 = add i32 %0, 131071 + ret i32 %2 +} + +define i32 @add2(i32 %0) { +; CHECK-LABEL: add2: +; CHECK: @ %bb.0: +; CHECK-NEXT: add r0, r0, #8960 +; CHECK-NEXT: add r0, r0, #2293760 +; CHECK-NEXT: mov pc, lr + %2 = add i32 %0, 2302720 + ret i32 %2 +}