1 ; RUN: llc -mtriple=arm64_32-apple-ios %s -o - | FileCheck %s
3 ; If %base < 96 then the sum will not wrap (in an unsigned sense), but "ldr w0,
5 define i32 @test_valid_wrap(i32 %base) {
6 ; CHECK-LABEL: test_valid_wrap:
7 ; CHECK: sub w[[ADDR:[0-9]+]], w0, #96
8 ; CHECK: ldr w0, [x[[ADDR]]]
10 %newaddr = add nuw i32 %base, -96
11 %ptr = inttoptr i32 %newaddr to i32*
12 %val = load i32, i32* %ptr
16 define i8 @test_valid_wrap_optimizable(i8* %base) {
17 ; CHECK-LABEL: test_valid_wrap_optimizable:
18 ; CHECK: ldurb w0, [x0, #-96]
20 %newaddr = getelementptr inbounds i8, i8* %base, i32 -96
21 %val = load i8, i8* %newaddr
25 define i8 @test_valid_wrap_optimizable1(i8* %base, i32 %offset) {
26 ; CHECK-LABEL: test_valid_wrap_optimizable1:
27 ; CHECK: ldrb w0, [x0, w1, sxtw]
29 %newaddr = getelementptr inbounds i8, i8* %base, i32 %offset
30 %val = load i8, i8* %newaddr
35 define i8 @test_valid_wrap_optimizable2(i8* %base, i32 %offset) {
36 ; CHECK-LABEL: test_valid_wrap_optimizable2:
37 ; CHECK: sxtw x[[OFFSET:[0-9]+]], w1
38 ; CHECK: mov w[[BASE:[0-9]+]], #-100
39 ; CHECK: ldrb w0, [x[[OFFSET]], x[[BASE]]]
41 %newaddr = getelementptr inbounds i8, i8* inttoptr(i32 -100 to i8*), i32 %offset
42 %val = load i8, i8* %newaddr