public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/114061] New: GCC fails vectorization when using __builtin_prefetch
@ 2024-02-22 19:04 tnfchris at gcc dot gnu.org
  2024-02-22 19:07 ` [Bug tree-optimization/114061] " pinskia at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: tnfchris at gcc dot gnu.org @ 2024-02-22 19:04 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 114061
           Summary: GCC fails vectorization when using __builtin_prefetch
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tnfchris at gcc dot gnu.org
  Target Milestone: ---

The following example:

void foo(double * restrict a, double * restrict b, int n){
  int i;
  for(i=0; i<n; ++i){
    a[i] = a[i] + b[i];
    __builtin_prefetch(&(b[i+8]));
  }
}

fails to vectorize because of the __builtin_prefetch.

/app/example.c:5:5: missed:  statement clobbers memory: __builtin_prefetch
(_10);
/app/example.c:3:13: missed:  not vectorized: loop contains function calls or
data references that cannot be analyzed

However two things:

1. prefetching are usually hints anyway and not a correctness thing.  It should
be safe to elide the call and vectorizer as normal.
2. SVE has prefetched vector operations which we can use here.  The vector
prefetches are also predicated so they need to be actually codegened.

Perhaps one solution here would be to have a vect-pattern which checks for
COND_PREFETCH support if supported, and if not just elides the prefetch?

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-06-12 17:15 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-22 19:04 [Bug tree-optimization/114061] New: GCC fails vectorization when using __builtin_prefetch tnfchris at gcc dot gnu.org
2024-02-22 19:07 ` [Bug tree-optimization/114061] " pinskia at gcc dot gnu.org
2024-02-22 19:09 ` tnfchris at gcc dot gnu.org
2024-02-22 19:11 ` pinskia at gcc dot gnu.org
2024-02-22 19:21 ` tnfchris at gcc dot gnu.org
2024-02-23  7:01 ` rguenth at gcc dot gnu.org
2024-04-08 14:01 ` victorldn at gcc dot gnu.org
2024-06-12 13:39 ` cvs-commit at gcc dot gnu.org
2024-06-12 17:15 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).