Skip to content

Commit b7e11b4

Browse files
testsuite: arm: Check that a far jump is used in thumb1-far-jump-2.c
With the changes in r15-1579-g792f97b44ff, the code used as "padding" in the test case is optimized way. Prevent this optimization by forcing a read of the volatile memory. Also, validate that there is a far jump in the generated assembler. Without this patch, the generated assembler is reduced to: f3: cmp r0, #0 beq .L1 ldr r4, .L6 .L1: bx lr .L7: .align 2 .L6: .word g_0_1 With the patch, the generated assembler is: f3: movs r2, #1 ldr r3, .L6 push {lr} str r2, [r3] cmp r0, #0 bne .LCB10 bl .L1 @far jump .LCB10: b .L7 .L8: .align 2 .L6: .word .LANCHOR0 .L7: str r2, [r3] ... str r2, [r3] .L1: pop {pc} gcc/testsuite/ChangeLog: * gcc.target/arm/thumb1-far-jump-2.c: Write to volatile memmory in macro to avoid optimization. Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
1 parent 95a0c71 commit b7e11b4

File tree

1 file changed

+51
-44
lines changed

1 file changed

+51
-44
lines changed

gcc/testsuite/gcc.target/arm/thumb1-far-jump-2.c

Lines changed: 51 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -5,53 +5,60 @@
55
/* { dg-options "-Os" } */
66
/* { dg-skip-if "" { ! { arm_thumb1 } } } */
77

8-
volatile register int r4 asm ("r4");
8+
volatile int r4;
9+
10+
#define GO() \
11+
r4 = 1;
12+
13+
#define GO8() \
14+
GO() \
15+
GO() \
16+
GO() \
17+
GO() \
18+
GO() \
19+
GO() \
20+
GO() \
21+
GO()
22+
23+
#define GO32() \
24+
GO8() \
25+
GO8() \
26+
GO8() \
27+
GO8()
28+
29+
#define GO128() \
30+
GO32() \
31+
GO32() \
32+
GO32() \
33+
GO32()
34+
35+
#define GO512() \
36+
GO128() \
37+
GO128() \
38+
GO128() \
39+
GO128()
40+
41+
#define GO1018() \
42+
GO512() \
43+
GO128() \
44+
GO128() \
45+
GO128() \
46+
GO32() \
47+
GO32() \
48+
GO32() \
49+
GO8() \
50+
GO8() \
51+
GO8() \
52+
GO() \
53+
GO()
54+
955
void f3(int i)
1056
{
11-
#define GO(n) \
12-
extern volatile int g_##n; \
13-
r4=(int)&g_##n;
14-
15-
#define GO8(n) \
16-
GO(n##_0) \
17-
GO(n##_1) \
18-
GO(n##_2) \
19-
GO(n##_3) \
20-
GO(n##_4) \
21-
GO(n##_5) \
22-
GO(n##_6) \
23-
GO(n##_7)
24-
25-
#define GO64(n) \
26-
GO8(n##_0) \
27-
GO8(n##_1) \
28-
GO8(n##_2) \
29-
GO8(n##_3) \
30-
GO8(n##_4) \
31-
GO8(n##_5) \
32-
GO8(n##_6) \
33-
GO8(n##_7) \
34-
35-
#define GO498(n) \
36-
GO64(n##_0) \
37-
GO64(n##_1) \
38-
GO64(n##_2) \
39-
GO64(n##_3) \
40-
GO64(n##_4) \
41-
GO64(n##_5) \
42-
GO64(n##_6) \
43-
GO8(n##_0) \
44-
GO8(n##_1) \
45-
GO8(n##_2) \
46-
GO8(n##_3) \
47-
GO8(n##_4) \
48-
GO8(n##_5) \
49-
GO(n##_0) \
50-
GO(n##_1) \
51-
57+
GO();
5258
if (i) {
53-
GO498(0);
59+
GO1018();
5460
}
5561
}
5662

57-
/* { dg-final { scan-assembler "push.*lr" } } */
63+
/* { dg-final { scan-assembler "\tpush.*lr" } } */
64+
/* { dg-final { scan-assembler "\tbl\t\\.L\[0-9\]+\t@far jump" } } */

0 commit comments

Comments
 (0)