(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.target/
aarch64/
reg-alloc-3.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  void ext();
      14  
      15  /* The thing we're testing here is that the !head->inner path of the outer loop
      16     body has no stack accesses.  It's possible that we'll need to update this
      17     pattern for unrelated code changes. but the test should be XFAILed rather
      18     than changed if any new stack accesses creep into the !head->inner path.  */
      19  /*
      20  ** foo:
      21  **	...
      22  **	ldr	(w[0-9]+), \[(x[0-9]+)\]
      23  **	add	(w[0-9]+), (?:\3, \1|\1, \3)
      24  **	ldr	(x[0-9]+), \[\2, #?16\]
      25  **	str	\3, \[\2\]
      26  **	ldr	\2, \[\2, #?8\]
      27  **	cbn?z	\4, .*
      28  **	...
      29  **	ret
      30  */
      31  void
      32  foo (volatile struct L *head, int inc, double *ptr)
      33  {
      34    double d = *ptr;
      35    while (head)
      36      {
      37        /* Clobber all call-preserved GPRs, so that the loop has to use
      38  	 call-clobbered GPRs if it is to avoid spilling.  */
      39        asm volatile ("" :::
      40  		    "x19", "x20", "x21", "x22", "x23",
      41  		    "x24", "x25", "x26", "x27", "x28");
      42        inc = head->data + inc;
      43        volatile struct L *inner = head->inner;
      44        head->data = inc;
      45        head = head->next;
      46        if (__builtin_expect_with_probability (inner != 0, 0, PROB))
      47  	for (int i = 0; i < 1000; ++i)
      48  	  {
      49  	    ext ();
      50  	    /* Hack to create high register pressure, so that IRA doesn't
      51  	       collapse this loop into the parent loop.  */
      52  	    d += 1;
      53  	    asm volatile ("// foo" :::
      54  			  "d0", "d1", "d2", "d3",
      55  			  "d4", "d5", "d6", "d7",
      56  			  "d8", "d9", "d10", "d11",
      57  			  "d12", "d13", "d14", "d15",
      58  			  "d16", "d17", "d18", "d19",
      59  			  "d20", "d21", "d22", "d23",
      60  			  "d24", "d25", "d26", "d27",
      61  			  "d28", "d29", "d30", "d31");
      62  	  }
      63      }
      64    *ptr = d;
      65  }