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

            Bug ID: 122732
           Summary: Add __builtin_assume_dereferenceable(a,N)  which tells
                    the compiler *a ... *(a+(N-1)/sizeof(*a)) is not
                    trapping
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

clang added __builtin_assume_dereferenceable recently
(https://github.com/llvm/llvm-project/pull/121789).

Basically it corresponds to the idea that `*a ... *(a+(N-1)/sizeof(*a))` will
not trap.  This seems like a good hint for the vectorizer and CSelim and ifcvt
(and other passes). How to communicate that information further down the IR is
still an open question. But at least accepting the builtin is a good first step
...

Reply via email to