xref: /llvm-project/llvm/test/CodeGen/Hexagon/imm-range-check.ll (revision 2208c97c1bec2512d4e47b6223db6d95a7037956)
1; RUN: llc -mtriple=hexagon -filetype=obj < %s | llvm-objdump -d - | FileCheck %s
2
3; The output assembly (textual) contains the instruction
4;   r29 = add(r29,#4294967136)
5; The value 4294967136 is -160 when interpreted as a signed 32-bit
6; integer, so it fits in the range of the immediate operand without
7; a constant extender. The range check in HexagonInstrInfo was putting
8; the operand value into an int variable, reporting no need for an
9; extender. This resulted in a packet with 4 instructions, including
10; the "add". The corresponding check in HexagonMCInstrInfo was using
11; an int64_t variable, causing an extender to be emitted when lowering
12; to MCInst, and resulting in a packet with 5 instructions.
13
14; Check that this doesn't crash.
15; CHECK: r29 = add(r29,#-0xa0)
16
17target triple = "hexagon-unknown-linux-gnu"
18
19define float @f0() {
20b0:
21  %v0 = alloca i8, i32 0, align 1
22  %v1 = alloca float, i32 -42, align 4
23  %v2 = load float, ptr %v1, align 4
24  store i8 0, ptr %v0, align 1
25  ret float %v2
26}
27