(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.target/
aarch64/
reg-alloc-4.c
       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        /* Clobber all call-preserved GPRs, so that the loop has to use
      35  	 call-clobbered GPRs if it is to avoid spilling.  */
      36        asm volatile ("" :::
      37  		    "x19", "x20", "x21", "x22", "x23",
      38  		    "x24", "x25", "x26", "x27", "x28");
      39        inc = head->data + inc;
      40        volatile struct L *inner = head->inner;
      41        head->data = inc;
      42        head = head->next;
      43        if (__builtin_expect_with_probability (inner != 0, 0, PROB))
      44  	for (int i = 0; i < 1000; ++i)
      45  	  asm volatile ("" ::			/* example allocation: */
      46  			"r" (i),		/* x0 */
      47  			"r" (inner),		/* x1 */
      48  			"r" (inner->next),	/* x2 */
      49  			"r" (inner->next),	/* x3 */
      50  			"r" (inner->next),	/* x4 */
      51  			"r" (inner->next),	/* x5 */
      52  			"r" (inner->next),	/* x6 */
      53  			"r" (inner->next),	/* x7 */
      54  			"r" (inner->next),	/* x8 */
      55  			"r" (inner->next),	/* x9 */
      56  			"r" (inner->next),	/* x10 */
      57  			"r" (inner->next),	/* x11 */
      58  			"r" (inner->next),	/* x12 */
      59  			"r" (inner->next),	/* x13 */
      60  			"r" (inner->next),	/* x14 */
      61  			"r" (inner->next),	/* x15 */
      62  			"r" (inner->next),	/* x16 */
      63  			"r" (inner->next),	/* x17 */
      64  			"r" (inner->next),	/* x18 */
      65  			"r" (inner->next) :	/* x30 */
      66  			"x19", "x20", "x21", "x22", "x23",
      67  			"x24", "x25", "x26", "x27", "x28");
      68      }
      69  }