1 /* { dg-options "-O2 -fno-schedule-insns -fno-schedule-insns2" } */
2 /* { dg-final { check-function-bodies "**" "" "" { target lp64 } } } */
3
4 #define PROB 0.1
5
6 struct L
7 {
8 int data;
9 volatile struct L *next;
10 volatile struct L *inner;
11 };
12
13 /* The thing we're testing here is that the !head->inner path of the outer loop
14 body has no stack accesses. It's possible that we'll need to update this
15 pattern for unrelated code changes. but the test should be XFAILed rather
16 than changed if any new stack accesses occur on the !head->inner path. */
17 /*
18 ** foo:
19 ** ...
20 ** ldr (w[0-9]+), \[(x[0-9]+)\]
21 ** add (w[0-9]+), (?:\3, \1|\1, \3)
22 ** ldr (x[0-9]+), \[\2, #?16\]
23 ** str \3, \[\2\]
24 ** ldr \2, \[\2, #?8\]
25 ** cbn?z \4, .*
26 ** ...
27 ** ret
28 */
29 void
30 foo (volatile struct L *head, int inc)
31 {
32 while (head)
33 {
34 inc = head->data + inc;
35 volatile struct L *inner = head->inner;
36 head->data = inc;
37 head = head->next;
38 if (__builtin_expect_with_probability (inner != 0, 0, PROB))
39 for (int i = 0; i < 1000; ++i)
40 /* Leave x30 for i. */
41 asm volatile ("// foo" :::
42 "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7",
43 "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15",
44 "x16", "x17", "x18", "x19", "x20", "x21", "x22", "x23",
45 "x24", "x25", "x26", "x27", "x28");
46 }
47 }