<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - [11 regression] No elimination of conditional addition of zero"
   href="https://bugs.llvm.org/show_bug.cgi?id=47730">47730</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[11 regression] No elimination of conditional addition of zero
          </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>Windows NT
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Scalar Optimizations
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>david.bolvansky@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>struct vector {
    int *data;
    unsigned long size;
};


int *vector_end_zero_add(struct vector *vec)
{
    if (vec->size == 0)
        return vec->data;
    return vec->data + vec->size;
}




Trunk:
vector_end_zero_add(vector*): # @vector_end_zero_add(vector*)
  mov rcx, qword ptr [rdi]
  mov rax, qword ptr [rdi + 8]
  test rax, rax
  lea rax, [rcx + 4*rax]
  cmove rax, rcx
  ret


10.0.1:
vector_end_zero_add(vector*): # @vector_end_zero_add(vector*)
  mov rax, qword ptr [rdi + 8]
  shl rax, 2
  add rax, qword ptr [rdi]
  ret


What is really weird, with "unsigned size;", even Clang 10.0.1 cannot optimize
it.

Current codegen:
<a href="https://godbolt.org/z/1Pr43K">https://godbolt.org/z/1Pr43K</a></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>