public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/110915] New: vector version of `x == MIN & x > y` is not optimized
@ 2023-08-05 17:11 pinskia at gcc dot gnu.org
  2023-08-05 17:11 ` [Bug tree-optimization/110915] " pinskia at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-05 17:11 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110915
           Summary: vector version of `x == MIN & x > y` is not optimized
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: pinskia at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

Example:
```
#include <limits.h>

#define vector __attribute__((vector_size(sizeof(unsigned)*2)))

vector signed fs(vector signed x, vector signed y)
{
  vector signed t = x == INT_MIN;
  vector signed t1 = x > y;
  return t & t1;
}
vector signed fu(vector unsigned x, vector unsigned y)
{
  vector signed t = x == 0;
  vector signed t1 = x > y;
  return t & t1;
}

 signed f2_1( signed x,  signed y)
{
   signed t = x == INT_MIN;
   signed t1 = x > y;
  return t & t1;
}
```

I am filing this as I am fixing the pointer version (PR 96695) and don't want
to lose track of this either.

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

* [Bug tree-optimization/110915] vector version of `x == MIN & x > y` is not optimized
  2023-08-05 17:11 [Bug tree-optimization/110915] New: vector version of `x == MIN & x > y` is not optimized pinskia at gcc dot gnu.org
@ 2023-08-05 17:11 ` pinskia at gcc dot gnu.org
  2023-08-05 17:25 ` pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-05 17:11 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2023-08-05

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

* [Bug tree-optimization/110915] vector version of `x == MIN & x > y` is not optimized
  2023-08-05 17:11 [Bug tree-optimization/110915] New: vector version of `x == MIN & x > y` is not optimized pinskia at gcc dot gnu.org
  2023-08-05 17:11 ` [Bug tree-optimization/110915] " pinskia at gcc dot gnu.org
@ 2023-08-05 17:25 ` pinskia at gcc dot gnu.org
  2023-08-21 20:13 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-05 17:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
These should work, I think, will try after finishing up the pointer:
(match min_value
 VECTOR_CST
 (with { tree inner = uniform_integer_cst_p (t); }
  (if (inner
       && INTEGRAL_TYPE_P (TREE_TYPE (inner))
       && wi::eq_p (wi::to_wide (inner), wi::min_value (TREE_TYPE (inner))))
  )
 )
)

(match max_value
 VECTOR_CST
 (with { tree inner = uniform_integer_cst_p (t); }
  (if (inner
       && INTEGRAL_TYPE_P (TREE_TYPE (inner))
       && wi::eq_p (wi::to_wide (inner), wi::max_value (TREE_TYPE (inner))))
  )
 )
)

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

* [Bug tree-optimization/110915] vector version of `x == MIN & x > y` is not optimized
  2023-08-05 17:11 [Bug tree-optimization/110915] New: vector version of `x == MIN & x > y` is not optimized pinskia at gcc dot gnu.org
  2023-08-05 17:11 ` [Bug tree-optimization/110915] " pinskia at gcc dot gnu.org
  2023-08-05 17:25 ` pinskia at gcc dot gnu.org
@ 2023-08-21 20:13 ` pinskia at gcc dot gnu.org
  2023-08-30 22:27 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-21 20:13 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #1)
> These should work, I think, will try after finishing up the pointer:


This is better version, it replaces the current min_value/max_value even:
(match min_value
 uniform_integer_cst_p
 (with { tree int_cst = uniform_integer_cst_p (t); }
  (if ((INTEGRAL_TYPE_P (TREE_TYPE (int_cst))
        || POINTER_TYPE_P (TREE_TYPE (int_cst)))
       && wi::eq_p (wi::to_wide (int_cst),
                    wi::min_value (TREE_TYPE (int_cst))))
 )
)

(match max_value
 uniform_integer_cst_p
 (with { tree int_cst = uniform_integer_cst_p (t); }
  (if ((INTEGRAL_TYPE_P (TREE_TYPE (int_cst))
        || POINTER_TYPE_P (TREE_TYPE (int_cst)))
       && wi::eq_p (wi::to_wide (int_cst),
                    wi::max_value (TREE_TYPE (int_cst))))
 )
)

That is INTEGER_CST replace with uniform_integer_cst_p and type with TREE_TYPE
(int_cst) and t with int_cst.

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

* [Bug tree-optimization/110915] vector version of `x == MIN & x > y` is not optimized
  2023-08-05 17:11 [Bug tree-optimization/110915] New: vector version of `x == MIN & x > y` is not optimized pinskia at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2023-08-21 20:13 ` pinskia at gcc dot gnu.org
@ 2023-08-30 22:27 ` pinskia at gcc dot gnu.org
  2023-08-31 17:26 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-30 22:27 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
                URL|                            |https://gcc.gnu.org/piperma
                   |                            |il/gcc-patches/2023-August/
                   |                            |628869.html

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Patch posted:
https://gcc.gnu.org/pipermail/gcc-patches/2023-August/628869.html

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

* [Bug tree-optimization/110915] vector version of `x == MIN & x > y` is not optimized
  2023-08-05 17:11 [Bug tree-optimization/110915] New: vector version of `x == MIN & x > y` is not optimized pinskia at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2023-08-30 22:27 ` pinskia at gcc dot gnu.org
@ 2023-08-31 17:26 ` cvs-commit at gcc dot gnu.org
  2023-08-31 17:27 ` pinskia at gcc dot gnu.org
  2023-09-01 12:19 ` cvs-commit at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-08-31 17:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Andrew Pinski <pinskia@gcc.gnu.org>:

https://gcc.gnu.org/g:16a268785f646b3d641acd8634ab487b24f51c33

commit r14-3603-g16a268785f646b3d641acd8634ab487b24f51c33
Author: Andrew Pinski <apinski@marvell.com>
Date:   Wed Aug 30 12:27:06 2023 -0700

    MATCH: extend min_value/max_value match to vectors

    This simple patch extends the min_value/max_value match to vector integer
types.
    Using uniform_integer_cst_p makes this easy.

    OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

    The testcases pr110915-*.c are the same as pr88784-*.c except using vector
    types instead.

            PR tree-optimization/110915

    gcc/ChangeLog:

            * match.pd (min_value, max_value): Extend to vector constants.

    gcc/testsuite/ChangeLog:

            * gcc.dg/pr110915-1.c: New test.
            * gcc.dg/pr110915-10.c: New test.
            * gcc.dg/pr110915-11.c: New test.
            * gcc.dg/pr110915-12.c: New test.
            * gcc.dg/pr110915-2.c: New test.
            * gcc.dg/pr110915-3.c: New test.
            * gcc.dg/pr110915-4.c: New test.
            * gcc.dg/pr110915-5.c: New test.
            * gcc.dg/pr110915-6.c: New test.
            * gcc.dg/pr110915-7.c: New test.
            * gcc.dg/pr110915-8.c: New test.
            * gcc.dg/pr110915-9.c: New test.

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

* [Bug tree-optimization/110915] vector version of `x == MIN & x > y` is not optimized
  2023-08-05 17:11 [Bug tree-optimization/110915] New: vector version of `x == MIN & x > y` is not optimized pinskia at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2023-08-31 17:26 ` cvs-commit at gcc dot gnu.org
@ 2023-08-31 17:27 ` pinskia at gcc dot gnu.org
  2023-09-01 12:19 ` cvs-commit at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-31 17:27 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED
   Target Milestone|---                         |14.0

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed.

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

* [Bug tree-optimization/110915] vector version of `x == MIN & x > y` is not optimized
  2023-08-05 17:11 [Bug tree-optimization/110915] New: vector version of `x == MIN & x > y` is not optimized pinskia at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2023-08-31 17:27 ` pinskia at gcc dot gnu.org
@ 2023-09-01 12:19 ` cvs-commit at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-09-01 12:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:b8df57b3221aac70f22fb5c93d0b95bf22fded90

commit r14-3622-gb8df57b3221aac70f22fb5c93d0b95bf22fded90
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri Sep 1 14:17:06 2023 +0200

    testsuite: Fix up pr110915* tests on i686-linux [PR110915]

    These tests FAIL on i686-linux, with
    .../gcc/testsuite/gcc.dg/pr110915-1.c:8:1: warning: MMX vector return
without MMX enabled changes the ABI [-Wpsabi]
    .../gcc/testsuite/gcc.dg/pr110915-1.c:7:15: warning: MMX vector argument
without MMX enabled changes the ABI [-Wpsabi]
    excess warnings.  I've added -Wno-psabi to quiet that up, plus I think
    it is undesirable to define macros like vector before including C library
    headers in case the header would use that identifier in non-obfuscated
    form somewhere.

    2023-09-01  Jakub Jelinek  <jakub@redhat.com>

            PR tree-optimization/110915
            * gcc.dg/pr110915-1.c: Add -Wno-psabi to dg-options.  Move vector
            macro definition after limits.h inclusion.
            * gcc.dg/pr110915-2.c: Likewise.
            * gcc.dg/pr110915-3.c: Likewise.
            * gcc.dg/pr110915-4.c: Likewise.
            * gcc.dg/pr110915-5.c: Likewise.
            * gcc.dg/pr110915-6.c: Likewise.
            * gcc.dg/pr110915-7.c: Likewise.
            * gcc.dg/pr110915-8.c: Likewise.
            * gcc.dg/pr110915-9.c: Likewise.
            * gcc.dg/pr110915-10.c: Likewise.
            * gcc.dg/pr110915-11.c: Likewise.
            * gcc.dg/pr110915-12.c: Likewise.

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

end of thread, other threads:[~2023-09-01 12:19 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-05 17:11 [Bug tree-optimization/110915] New: vector version of `x == MIN & x > y` is not optimized pinskia at gcc dot gnu.org
2023-08-05 17:11 ` [Bug tree-optimization/110915] " pinskia at gcc dot gnu.org
2023-08-05 17:25 ` pinskia at gcc dot gnu.org
2023-08-21 20:13 ` pinskia at gcc dot gnu.org
2023-08-30 22:27 ` pinskia at gcc dot gnu.org
2023-08-31 17:26 ` cvs-commit at gcc dot gnu.org
2023-08-31 17:27 ` pinskia at gcc dot gnu.org
2023-09-01 12:19 ` 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).