blob: 274add33898b4443aac26ca81505f597de225b1f [file] [log] [blame]
Colin LeMahieub8575b12015-06-13 21:46:39 +00001; RUN: llc -march=hexagon < %s | FileCheck %s
2;
3; Bug 6840. Use absolute+index addressing.
4
5@ga = common global [1024 x i8] zeroinitializer, align 8
Colin LeMahieub8575b12015-06-13 21:46:39 +00006
Krzysztof Parzyszek64e5d7d2017-10-20 19:33:12 +00007; CHECK-LABEL: test0
8; CHECK: memub(r{{[0-9]+}}+##ga)
9define zeroext i8 @test0(i32 %i) nounwind readonly {
Colin LeMahieub8575b12015-06-13 21:46:39 +000010entry:
Krzysztof Parzyszek64e5d7d2017-10-20 19:33:12 +000011 %t = getelementptr inbounds [1024 x i8], [1024 x i8]* @ga, i32 0, i32 %i
12 %0 = load i8, i8* %t, align 1
Colin LeMahieub8575b12015-06-13 21:46:39 +000013 ret i8 %0
14}
15
Krzysztof Parzyszek64e5d7d2017-10-20 19:33:12 +000016; CHECK-LABEL: test1
17; CHECK: memb(r{{[0-9]+}}+##ga)
18define signext i8 @test1(i32 %i) nounwind readonly {
Colin LeMahieub8575b12015-06-13 21:46:39 +000019entry:
Krzysztof Parzyszek64e5d7d2017-10-20 19:33:12 +000020 %t = getelementptr inbounds [1024 x i8], [1024 x i8]* @ga, i32 0, i32 %i
21 %0 = load i8, i8* %t, align 1
Colin LeMahieub8575b12015-06-13 21:46:39 +000022 ret i8 %0
23}
24
Krzysztof Parzyszek64e5d7d2017-10-20 19:33:12 +000025; CHECK-LABEL: test2
26; CHECK: memub(r{{[0-9]+}}<<#1+##ga)
27define zeroext i8 @test2(i32 %i) nounwind readonly {
Colin LeMahieub8575b12015-06-13 21:46:39 +000028entry:
Krzysztof Parzyszek64e5d7d2017-10-20 19:33:12 +000029 %j = shl nsw i32 %i, 1
30 %t = getelementptr inbounds [1024 x i8], [1024 x i8]* @ga, i32 0, i32 %j
31 %0 = load i8, i8* %t, align 1
Colin LeMahieub8575b12015-06-13 21:46:39 +000032 ret i8 %0
33}
34
Krzysztof Parzyszek64e5d7d2017-10-20 19:33:12 +000035; CHECK-LABEL: test3
36; CHECK: memb(r{{[0-9]+}}<<#1+##ga)
37define signext i8 @test3(i32 %i) nounwind readonly {
Colin LeMahieub8575b12015-06-13 21:46:39 +000038entry:
Krzysztof Parzyszek64e5d7d2017-10-20 19:33:12 +000039 %j = shl nsw i32 %i, 1
40 %t = getelementptr inbounds [1024 x i8], [1024 x i8]* @ga, i32 0, i32 %j
41 %0 = load i8, i8* %t, align 1
Colin LeMahieub8575b12015-06-13 21:46:39 +000042 ret i8 %0
43}
44
Krzysztof Parzyszek64e5d7d2017-10-20 19:33:12 +000045; CHECK-LABEL: test4
46; CHECK: memub(r{{[0-9]+}}<<#2+##ga)
47define zeroext i8 @test4(i32 %i) nounwind readonly {
Colin LeMahieub8575b12015-06-13 21:46:39 +000048entry:
Krzysztof Parzyszek64e5d7d2017-10-20 19:33:12 +000049 %j = shl nsw i32 %i, 2
50 %t = getelementptr inbounds [1024 x i8], [1024 x i8]* @ga, i32 0, i32 %j
51 %0 = load i8, i8* %t, align 1
52 ret i8 %0
53}
54
55; CHECK-LABEL: test5
56; CHECK: memb(r{{[0-9]+}}<<#2+##ga)
57define signext i8 @test5(i32 %i) nounwind readonly {
58entry:
59 %j = shl nsw i32 %i, 2
60 %t = getelementptr inbounds [1024 x i8], [1024 x i8]* @ga, i32 0, i32 %j
61 %0 = load i8, i8* %t, align 1
62 ret i8 %0
63}
64
65; CHECK-LABEL: test10
66; CHECK: memb(r{{[0-9]+}}+##ga)
67define void @test10(i32 %i, i8 zeroext %v) nounwind {
68entry:
69 %t = getelementptr inbounds [1024 x i8], [1024 x i8]* @ga, i32 0, i32 %i
70 store i8 %v, i8* %t, align 1
Colin LeMahieub8575b12015-06-13 21:46:39 +000071 ret void
72}
73
Krzysztof Parzyszek64e5d7d2017-10-20 19:33:12 +000074; CHECK-LABEL: test11
75; CHECK: memb(r{{[0-9]+}}<<#1+##ga)
76define void @test11(i32 %i, i8 signext %v) nounwind {
Colin LeMahieub8575b12015-06-13 21:46:39 +000077entry:
Krzysztof Parzyszek64e5d7d2017-10-20 19:33:12 +000078 %j = shl nsw i32 %i, 1
79 %t = getelementptr inbounds [1024 x i8], [1024 x i8]* @ga, i32 0, i32 %j
80 store i8 %v, i8* %t, align 1
Colin LeMahieub8575b12015-06-13 21:46:39 +000081 ret void
82}
83
Krzysztof Parzyszek64e5d7d2017-10-20 19:33:12 +000084; CHECK-LABEL: test12
85; CHECK: memb(r{{[0-9]+}}<<#2+##ga)
86define void @test12(i32 %i, i8 zeroext %v) nounwind {
Colin LeMahieub8575b12015-06-13 21:46:39 +000087entry:
Krzysztof Parzyszek64e5d7d2017-10-20 19:33:12 +000088 %j = shl nsw i32 %i, 2
89 %t = getelementptr inbounds [1024 x i8], [1024 x i8]* @ga, i32 0, i32 %j
90 store i8 %v, i8* %t, align 1
Colin LeMahieub8575b12015-06-13 21:46:39 +000091 ret void
92}