<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 - Failure to LICM-hoist load - AA imprecision?"
   href="https://bugs.llvm.org/show_bug.cgi?id=50933">50933</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Failure to LICM-hoist load - AA imprecision?
          </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>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Global Analyses
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>lebedev.ri@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I'm not quite confident there is actually to do on AA's side,
but this struck me as very surprising, so i better ask.

int foo();
int bar();

struct S {
    bool cond;
    int* data;

    void member(int width) const;
};

void S::member(int width) const {
    for(int i = 0; i != width; ++i) 
        data[i] = cond ? foo() : bar();
}


We currently fail to unswitch this loop: <a href="https://godbolt.org/z/f1zavYPs3">https://godbolt.org/z/f1zavYPs3</a>
I was really expecting we would.
It looks like we are failing to proove that `int* S::data` can not alias
with `&(bool S::cond)`: <a href="https://godbolt.org/z/3vbY3e8jz">https://godbolt.org/z/3vbY3e8jz</a>
And thus MSSA thinks it may be invalidated: <a href="https://godbolt.org/z/Yz4draeee">https://godbolt.org/z/Yz4draeee</a>

TBAA says that it's fine: <a href="https://godbolt.org/z/G4M6jEqcx">https://godbolt.org/z/G4M6jEqcx</a>

The obvious example of how we could arrive at that bad situation would be:
<a href="https://godbolt.org/z/bsrca77d1">https://godbolt.org/z/bsrca77d1</a> <- is that UB?

So in short, is my expectation incorrect here, and this can't be done for C++?
If not, where should i dig?</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>