public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/109011] New: missed optimization in presence of __builtin_ctz
@ 2023-03-03 14:56 vincenzo.innocente at cern dot ch
  2023-03-03 19:45 ` [Bug tree-optimization/109011] " pinskia at gcc dot gnu.org
                   ` (22 more replies)
  0 siblings, 23 replies; 24+ messages in thread
From: vincenzo.innocente at cern dot ch @ 2023-03-03 14:56 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109011
           Summary: missed optimization in presence of __builtin_ctz
           Product: gcc
           Version: 12.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vincenzo.innocente at cern dot ch
  Target Milestone: ---

in the following code foo does not vectorize, bar does.
clang vectorize foo using a pattern that invokes vplzcntd

(code made a bit complex to make vectorization "relevant") 

see https://godbolt.org/z/5fa1zbPeG

#include <cstdint>
uint32_t x[256];
uint32_t y[256];
uint32_t w[256];
uint32_t z[256];



void foo() {
  for (int i=0; i<256;i++) {
    auto p = x[i] ?  __builtin_ctz(x[i]) : y[i];
   z[i] = w[i]*p;
 }  
}


void bar() {
  for (int j=0; j<256;j+=8)
  for (int i=j; i<j+8;i++) {
   // auto p = x[i] ?  x[i] : y[i];
   auto p = x[i] ?  __builtin_ctz(x[i]) : y[i];
   z[i] = w[i]*p;
 }  
}

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

end of thread, other threads:[~2023-04-24  1:35 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-03 14:56 [Bug tree-optimization/109011] New: missed optimization in presence of __builtin_ctz vincenzo.innocente at cern dot ch
2023-03-03 19:45 ` [Bug tree-optimization/109011] " pinskia at gcc dot gnu.org
2023-03-03 19:48 ` pinskia at gcc dot gnu.org
2023-03-03 20:21 ` jakub at gcc dot gnu.org
2023-03-03 20:39 ` jakub at gcc dot gnu.org
2023-03-03 20:46 ` jakub at gcc dot gnu.org
2023-03-04  0:18 ` jakub at gcc dot gnu.org
2023-03-04 11:14 ` jakub at gcc dot gnu.org
2023-03-04 12:22 ` jakub at gcc dot gnu.org
2023-03-04 14:01 ` jakub at gcc dot gnu.org
2023-03-04 15:08 ` jakub at gcc dot gnu.org
2023-03-06  5:26 ` crazylht at gmail dot com
2023-03-06  7:01 ` jakub at gcc dot gnu.org
2023-03-06  7:59 ` crazylht at gmail dot com
2023-03-06  8:11 ` jakub at gcc dot gnu.org
2023-03-06  8:23 ` crazylht at gmail dot com
2023-03-06  8:32 ` jakub at gcc dot gnu.org
2023-03-06  9:22 ` jakub at gcc dot gnu.org
2023-03-14  9:24 ` crazylht at gmail dot com
2023-03-16  6:32 ` crazylht at gmail dot com
2023-04-19  9:15 ` cvs-commit at gcc dot gnu.org
2023-04-20  9:56 ` cvs-commit at gcc dot gnu.org
2023-04-20 17:45 ` cvs-commit at gcc dot gnu.org
2023-04-24  1:35 ` cvs-commit 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).