* [Bug tree-optimization/96695] Failure to optimize combination of pointer comparison to nullptr and another pointer
2020-08-18 23:53 [Bug tree-optimization/96695] New: Failure to optimize combination of pointer comparison to nullptr and another pointer gabravier at gmail dot com
@ 2020-08-18 23:57 ` gabravier at gmail dot com
2020-08-25 11:02 ` rguenth at gcc dot gnu.org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: gabravier at gmail dot com @ 2020-08-18 23:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96695
--- Comment #1 from Gabriel Ravier <gabravier at gmail dot com> ---
PS: Very similar transformations can be done with alike patterns like `(x == 0)
&& (x <= y)`, which can be optimized to `x == 0`.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/96695] Failure to optimize combination of pointer comparison to nullptr and another pointer
2020-08-18 23:53 [Bug tree-optimization/96695] New: Failure to optimize combination of pointer comparison to nullptr and another pointer gabravier at gmail dot com
2020-08-18 23:57 ` [Bug tree-optimization/96695] " gabravier at gmail dot com
@ 2020-08-25 11:02 ` rguenth at gcc dot gnu.org
2021-07-25 4:36 ` pinskia at gcc dot gnu.org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-08-25 11:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96695
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
Last reconfirmed| |2020-08-25
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Hmm, so we can optimize 0 > y to false, likewise 0 <= y to true. I guess we
already do that so VRP should handle
if (x == 0)
if (x > y)
already.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/96695] Failure to optimize combination of pointer comparison to nullptr and another pointer
2020-08-18 23:53 [Bug tree-optimization/96695] New: Failure to optimize combination of pointer comparison to nullptr and another pointer gabravier at gmail dot com
2020-08-18 23:57 ` [Bug tree-optimization/96695] " gabravier at gmail dot com
2020-08-25 11:02 ` rguenth at gcc dot gnu.org
@ 2021-07-25 4:36 ` pinskia at gcc dot gnu.org
2023-08-05 5:09 ` pinskia at gcc dot gnu.org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-25 4:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96695
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pinskia at gcc dot gnu.org
Severity|normal |enhancement
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/96695] Failure to optimize combination of pointer comparison to nullptr and another pointer
2020-08-18 23:53 [Bug tree-optimization/96695] New: Failure to optimize combination of pointer comparison to nullptr and another pointer gabravier at gmail dot com
` (2 preceding siblings ...)
2021-07-25 4:36 ` pinskia at gcc dot gnu.org
@ 2023-08-05 5:09 ` pinskia at gcc dot gnu.org
2023-08-05 16:28 ` pinskia at gcc dot gnu.org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-05 5:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96695
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |pinskia at gcc dot gnu.org
Status|NEW |ASSIGNED
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
We handle:
bool f2(unsigned x, unsigned y)
{
return (x == 0) && (x > y);
}
via:
/* x > y && x != XXX_MIN --> x > y
x > y && x == XXX_MIN --> false . */
min_value is defined as:
(match min_value
INTEGER_CST
(if (INTEGRAL_TYPE_P (type)
&& wi::eq_p (wi::to_wide (t), wi::min_value (type)))))
I suspect we could add POINTER_TYPE_P there and it will work.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/96695] Failure to optimize combination of pointer comparison to nullptr and another pointer
2020-08-18 23:53 [Bug tree-optimization/96695] New: Failure to optimize combination of pointer comparison to nullptr and another pointer gabravier at gmail dot com
` (3 preceding siblings ...)
2023-08-05 5:09 ` pinskia at gcc dot gnu.org
@ 2023-08-05 16:28 ` pinskia at gcc dot gnu.org
2023-08-05 21:28 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-05 16:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96695
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Created attachment 55694
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55694&action=edit
Patch which I am testing
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/96695] Failure to optimize combination of pointer comparison to nullptr and another pointer
2020-08-18 23:53 [Bug tree-optimization/96695] New: Failure to optimize combination of pointer comparison to nullptr and another pointer gabravier at gmail dot com
` (4 preceding siblings ...)
2023-08-05 16:28 ` pinskia at gcc dot gnu.org
@ 2023-08-05 21:28 ` pinskia at gcc dot gnu.org
2023-08-07 7:30 ` cvs-commit at gcc dot gnu.org
2023-08-07 7:30 ` pinskia at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-05 21:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96695
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/
| |626402.html
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Patch posted:
https://gcc.gnu.org/pipermail/gcc-patches/2023-August/626402.html
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/96695] Failure to optimize combination of pointer comparison to nullptr and another pointer
2020-08-18 23:53 [Bug tree-optimization/96695] New: Failure to optimize combination of pointer comparison to nullptr and another pointer gabravier at gmail dot com
` (5 preceding siblings ...)
2023-08-05 21:28 ` pinskia at gcc dot gnu.org
@ 2023-08-07 7:30 ` cvs-commit at gcc dot gnu.org
2023-08-07 7:30 ` pinskia at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-08-07 7:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96695
--- Comment #6 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:58f1e185ff6d108171b9c8ea043796c85a65fcec
commit r14-3014-g58f1e185ff6d108171b9c8ea043796c85a65fcec
Author: Andrew Pinski <apinski@marvell.com>
Date: Sat Aug 5 09:23:26 2023 -0700
MATCH: Extend min_value/max_value to pointer types
Since we already had the infrastructure to optimize
`(x == 0) && (x > y)` to false for integer types,
this extends the same to pointer types as indirectly
requested by PR 96695.
OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.
gcc/ChangeLog:
PR tree-optimization/96695
* match.pd (min_value, max_value): Extend to
pointer types too.
gcc/testsuite/ChangeLog:
PR tree-optimization/96695
* gcc.dg/pr96695-1.c: New test.
* gcc.dg/pr96695-10.c: New test.
* gcc.dg/pr96695-11.c: New test.
* gcc.dg/pr96695-12.c: New test.
* gcc.dg/pr96695-2.c: New test.
* gcc.dg/pr96695-3.c: New test.
* gcc.dg/pr96695-4.c: New test.
* gcc.dg/pr96695-5.c: New test.
* gcc.dg/pr96695-6.c: New test.
* gcc.dg/pr96695-7.c: New test.
* gcc.dg/pr96695-8.c: New test.
* gcc.dg/pr96695-9.c: New test.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/96695] Failure to optimize combination of pointer comparison to nullptr and another pointer
2020-08-18 23:53 [Bug tree-optimization/96695] New: Failure to optimize combination of pointer comparison to nullptr and another pointer gabravier at gmail dot com
` (6 preceding siblings ...)
2023-08-07 7:30 ` cvs-commit at gcc dot gnu.org
@ 2023-08-07 7:30 ` pinskia at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-07 7:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96695
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |14.0
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 9+ messages in thread