[llvm-bugs] [Bug 50933] New: Failure to LICM-hoist load - AA imprecision?

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jun 29 11:23:55 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=50933

            Bug ID: 50933
           Summary: Failure to LICM-hoist load - AA imprecision?
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Global Analyses
          Assignee: unassignedbugs at nondot.org
          Reporter: lebedev.ri at gmail.com
                CC: llvm-bugs at lists.llvm.org

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: https://godbolt.org/z/f1zavYPs3
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)`: https://godbolt.org/z/3vbY3e8jz
And thus MSSA thinks it may be invalidated: https://godbolt.org/z/Yz4draeee

TBAA says that it's fine: https://godbolt.org/z/G4M6jEqcx

The obvious example of how we could arrive at that bad situation would be:
https://godbolt.org/z/bsrca77d1 <- 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?

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210629/20c68e1e/attachment.html>


More information about the llvm-bugs mailing list