From: Victor Do Nascimento Date: Wed, 22 May 2024 11:14:11 +0000 (+0100) Subject: middle-end: Drop __builtin_prefetch calls in autovectorization [PR114061] X-Git-Tag: basepoints/gcc-16~8342 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=adcc815a01ae009d2768b6afb546e357bd37bbd2;p=thirdparty%2Fgcc.git middle-end: Drop __builtin_prefetch calls in autovectorization [PR114061] At present the autovectorizer fails to vectorize simple loops involving calls to `__builtin_prefetch'. A simple example of such loop is given below: void foo(double * restrict a, double * restrict b, int n){ int i; for(i=0; i *references) clobbers_memory = true; break; } + else if (gimple_call_builtin_p (stmt, BUILT_IN_PREFETCH)) + clobbers_memory = false; else clobbers_memory = true; } diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index 5b1ad06eca6..bbd5d261907 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -12185,8 +12185,10 @@ vect_transform_loop (loop_vec_info loop_vinfo, gimple *loop_vectorized_call) !gsi_end_p (si);) { stmt = gsi_stmt (si); - /* During vectorization remove existing clobber stmts. */ - if (gimple_clobber_p (stmt)) + /* During vectorization remove existing clobber stmts and + prefetches. */ + if (gimple_clobber_p (stmt) + || gimple_call_builtin_p (stmt, BUILT_IN_PREFETCH)) { unlink_stmt_vdef (stmt); gsi_remove (&si, true);