public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/111401] New: Middle-end: Missed optimization of MASK_LEN_FOLD_LEFT_PLUS
@ 2023-09-13  9:31 juzhe.zhong at rivai dot ai
  2023-09-13  9:46 ` [Bug c/111401] " rguenth at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: juzhe.zhong at rivai dot ai @ 2023-09-13  9:31 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111401
           Summary: Middle-end: Missed optimization of
                    MASK_LEN_FOLD_LEFT_PLUS
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: juzhe.zhong at rivai dot ai
  Target Milestone: ---

There is a case I think I missed the optimization in the loop vectorizer:

https://godbolt.org/z/x5sjdenhM

double
foo2 (double *__restrict a,
     double init,
     int *__restrict cond,
     int n)
{
    for (int i = 0; i < n; i++)
      if (cond[i])
        init += a[i];
    return init;
}

It generate the GIMPLE IR as follows:

_60 = .SELECT_VL (ivtmp_58, 4);
...
vect__ifc__35.14_56 = .VCOND_MASK (mask__23.10_50, vect__8.13_54, { 0.0, 0.0,
0.0, 0.0 });
  _36 = .MASK_LEN_FOLD_LEFT_PLUS (init_20, vect__ifc__35.14_56, { -1, -1, -1,
-1 }, _60, 0);

The mask of MASK_LEN_FOLD_LEFT_PLUS is the dummy mask {-1.-1,...-1}
I think we should forward the mask of VCOND_MASK into the
MASK_LEN_FOLD_LEFT_PLUS.

Then we can eliminate the VCOND_MASK.


I don't where is the optimal place to do the optimization.

Should be the match.pd ? or the loop vectorizer code?

Thanks.

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

end of thread, other threads:[~2023-11-02 22:40 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-13  9:31 [Bug c/111401] New: Middle-end: Missed optimization of MASK_LEN_FOLD_LEFT_PLUS juzhe.zhong at rivai dot ai
2023-09-13  9:46 ` [Bug c/111401] " rguenth at gcc dot gnu.org
2023-09-13 16:52 ` [Bug middle-end/111401] " rdapp at gcc dot gnu.org
2023-09-13 21:25 ` rdapp at gcc dot gnu.org
2023-09-14  6:46 ` rguenther at suse dot de
2023-09-14  6:51 ` rguenther at suse dot de
2023-09-14 15:07 ` rdapp at gcc dot gnu.org
2023-09-15  6:42 ` rguenth at gcc dot gnu.org
2023-11-02 10:50 ` cvs-commit at gcc dot gnu.org
2023-11-02 22:40 ` juzhe.zhong at rivai dot ai

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).