https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101993

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |missed-optimization
   Last reconfirmed|                            |2021-08-20
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
We can vectorize this with masked moves when using AVX2.  clang seems to simply
remove the test completely - C seems to guarantee that a + i is a valid pointer
if any of a + i is accessed and thus a + i is never NULL.

But then - just don't write such stupid checks?  What real-world code was
this testcase created from?

There is currently no optimization phase that would use loop info to elide NULL
pointer checks and I'm not sure where I'd put such.  Note the argument for
GCC would be that the access *(a + i) infers that a + i does not "overflow"
to another object (including NULL).  That's sth the points-to solver would
assume here (but the points-to solver is bad at tracking NULL).

Reply via email to