public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/113261] New: missing vectorization for dot_prod chain.
@ 2024-01-08  3:25 liuhongt at gcc dot gnu.org
  2024-01-08  3:29 ` [Bug tree-optimization/113261] " liuhongt at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: liuhongt at gcc dot gnu.org @ 2024-01-08  3:25 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 113261
           Summary: missing vectorization for dot_prod chain.
           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: liuhongt at gcc dot gnu.org
            Blocks: 53947
  Target Milestone: ---

int
foo (char* a, char* b, char* c, char* d)
{
    int sum = 0;
    for (int i = 0; i != 32; i++)
    {
        sum += (a[i] * b[i] + c[i] * d[i]);
    }
    return sum;
}


int
foo1 (char* a, char* b, char* c, char* d)
{
    int sum = 0;
    int sum1 = 0;
    for (int i = 0; i != 32; i++)
    {
        sum += a[i] * b[i]
        sum1 += c[i] * d[i];
    }
    return sum + sum1;
}

foo should be same as foo1, but it failed to be optimized to dot_prod_expr
since current vect_recog_dot_prod_pattern only recognize sum += a[i] * b[i];

I think it can be extend to recog dot_prod_expr chain, as long as they're only
used by the final sum reduction.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53947
[Bug 53947] [meta-bug] vectorizer missed-optimizations

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

* [Bug tree-optimization/113261] missing vectorization for dot_prod chain.
  2024-01-08  3:25 [Bug tree-optimization/113261] New: missing vectorization for dot_prod chain liuhongt at gcc dot gnu.org
@ 2024-01-08  3:29 ` liuhongt at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: liuhongt at gcc dot gnu.org @ 2024-01-08  3:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Hongtao Liu <liuhongt at gcc dot gnu.org> ---
For foo1, 

  _99 = .REDUC_PLUS (vect_patt_79.51_97);
  _90 = .REDUC_PLUS (vect_patt_28.43_88);
  _19 = _90 + _99;

can be optimized to 

   _tmp = vect_patt_79.51_97 + vect_patt_28.43_88;
   _19 = .REDUC_PLUS (_tmp);

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

end of thread, other threads:[~2024-01-08  3:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-08  3:25 [Bug tree-optimization/113261] New: missing vectorization for dot_prod chain liuhongt at gcc dot gnu.org
2024-01-08  3:29 ` [Bug tree-optimization/113261] " liuhongt 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).