• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -mtriple=aarch64_be -o - %s | FileCheck %s --check-prefix CHECK-BE
3; RUN: llc -mtriple=aarch64 -o - %s | FileCheck %s --check-prefix CHECK-LE
4
5define i8 @test1(i32 %a, i8* %pa) {
6; CHECK-BE-LABEL: test1:
7; CHECK-BE:       // %bb.0:
8; CHECK-BE-NEXT:    str w0, [x1]
9; CHECK-BE-NEXT:    ldrb w0, [x1]
10; CHECK-BE-NEXT:    ret
11;
12; CHECK-LE-LABEL: test1:
13; CHECK-LE:       // %bb.0:
14; CHECK-LE-NEXT:    str w0, [x1]
15; CHECK-LE-NEXT:    ret
16  %p32 = bitcast i8* %pa to i32*
17  %p8 = getelementptr i8, i8* %pa, i32 0
18  store i32 %a, i32* %p32
19  %res = load i8, i8* %p8
20  ret i8 %res
21}
22
23define i8 @test2(i32 %a, i8* %pa) {
24; CHECK-BE-LABEL: test2:
25; CHECK-BE:       // %bb.0:
26; CHECK-BE-NEXT:    str w0, [x1]
27; CHECK-BE-NEXT:    ldrb w0, [x1, #1]
28; CHECK-BE-NEXT:    ret
29;
30; CHECK-LE-LABEL: test2:
31; CHECK-LE:       // %bb.0:
32; CHECK-LE-NEXT:    str w0, [x1]
33; CHECK-LE-NEXT:    ubfx w0, w0, #8, #8
34; CHECK-LE-NEXT:    ret
35  %p32 = bitcast i8* %pa to i32*
36  %p8 = getelementptr i8, i8* %pa, i32 1
37  store i32 %a, i32* %p32
38  %res = load i8, i8* %p8
39  ret i8 %res
40}
41
42define i8 @test3(i32 %a, i8* %pa) {
43; CHECK-BE-LABEL: test3:
44; CHECK-BE:       // %bb.0:
45; CHECK-BE-NEXT:    str w0, [x1]
46; CHECK-BE-NEXT:    ldrb w0, [x1, #2]
47; CHECK-BE-NEXT:    ret
48;
49; CHECK-LE-LABEL: test3:
50; CHECK-LE:       // %bb.0:
51; CHECK-LE-NEXT:    str w0, [x1]
52; CHECK-LE-NEXT:    ubfx w0, w0, #16, #8
53; CHECK-LE-NEXT:    ret
54  %p32 = bitcast i8* %pa to i32*
55  %p8 = getelementptr i8, i8* %pa, i32 2
56  store i32 %a, i32* %p32
57  %res = load i8, i8* %p8
58  ret i8 %res
59}
60
61define i8 @test4(i32 %a, i8* %pa) {
62; CHECK-BE-LABEL: test4:
63; CHECK-BE:       // %bb.0:
64; CHECK-BE-NEXT:    str w0, [x1]
65; CHECK-BE-NEXT:    ret
66;
67; CHECK-LE-LABEL: test4:
68; CHECK-LE:       // %bb.0:
69; CHECK-LE-NEXT:    str w0, [x1]
70; CHECK-LE-NEXT:    lsr w0, w0, #24
71; CHECK-LE-NEXT:    ret
72  %p32 = bitcast i8* %pa to i32*
73  %p8 = getelementptr i8, i8* %pa, i32 3
74  store i32 %a, i32* %p32
75  %res = load i8, i8* %p8
76  ret i8 %res
77}
78