<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - [Cyclone] Register spills related to FeatureZCZeroing"
   href="https://llvm.org/bugs/show_bug.cgi?id=27454">27454</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[Cyclone] Register spills related to FeatureZCZeroing
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Backend: AArch64
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>haicheng@codeaurora.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>gberry@codeaurora.org, llvm-bugs@lists.llvm.org, mcrosier@codeaurora.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=16245" name="attach_16245" title="a .ll test case that has extra register spills if using -mcpu=cyclone">attachment 16245</a> <a href="attachment.cgi?id=16245&action=edit" title="a .ll test case that has extra register spills if using -mcpu=cyclone">[details]</a></span>
a .ll test case that has extra register spills if using -mcpu=cyclone

I am trying to port FeatureZCZeroing from Cyclone to Kryo. Using immediate #0
to zero out W and X registers works great in Kryo.  But using #0 to zero out
float registers sometimes causes extra register spills or move instructions on
either Cyclone or Kryo.

I attached a reduced IR test case which basically corresponds to the following
C code

double foo(int n) {
  double r=-10000;     
  for (int i=0;i<n;i++) {     
    x = sin(i);                                                         
    r = max(r,x);
  }     
  return(-r);   
}

If compiled towards Cyclone, the loop body has one spill and two reloads as
below

.LBB0_1:                                // %for.body
                                        // =>This Inner Loop Header: Depth=1
    str        q0, [sp]        // 16-byte Folded Spill
    ldr        q0, [sp]        // 16-byte Folded Reload
    bl    sin
    fmaxnm    d8, d8, d0
    ldr        q0, [sp]        // 16-byte Folded Reload
    fadd    d0, d0, d9
    add    w20, w20, #1            // =1
    cmp        w20, w19
    b.lt    .LBB0_1

If FeatureZCZeroing is disabled (together with FeatureZCRegMove) on Cyclone,
the translated assembly does not have these load/store instructions:

.LBB0_1:                                // %for.body
                                        // =>This Inner Loop Header: Depth=1
    mov        v0.16b, v8.16b
    bl    sin
    fmaxnm    d9, d9, d0
    fadd    d8, d8, d10
    add    w20, w20, #1            // =1
    cmp        w20, w19
    b.lt    .LBB0_1</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>