* [Bug tree-optimization/95185] Failure to optimize specific kind of sign comparison check
2020-05-18 12:05 [Bug tree-optimization/95185] New: Failure to optimize specific kind of sign comparison check gabravier at gmail dot com
@ 2020-05-18 13:15 ` rguenth at gcc dot gnu.org
2020-05-18 13:16 ` rguenth at gcc dot gnu.org
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-05-18 13:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95185
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Keywords| |easyhack,
| |missed-optimization
Last reconfirmed| |2020-05-18
Status|UNCONFIRMED |NEW
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/95185] Failure to optimize specific kind of sign comparison check
2020-05-18 12:05 [Bug tree-optimization/95185] New: Failure to optimize specific kind of sign comparison check gabravier at gmail dot com
2020-05-18 13:15 ` [Bug tree-optimization/95185] " rguenth at gcc dot gnu.org
@ 2020-05-18 13:16 ` rguenth at gcc dot gnu.org
2021-10-04 23:02 ` arjun.is at lostca dot se
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-05-18 13:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95185
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Btw, thanks for all these bugreports!
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/95185] Failure to optimize specific kind of sign comparison check
2020-05-18 12:05 [Bug tree-optimization/95185] New: Failure to optimize specific kind of sign comparison check gabravier at gmail dot com
2020-05-18 13:15 ` [Bug tree-optimization/95185] " rguenth at gcc dot gnu.org
2020-05-18 13:16 ` rguenth at gcc dot gnu.org
@ 2021-10-04 23:02 ` arjun.is at lostca dot se
2021-10-04 23:12 ` pinskia at gcc dot gnu.org
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: arjun.is at lostca dot se @ 2021-10-04 23:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95185
Arjun Shankar <arjun.is at lostca dot se> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |arjun.is at lostca dot se
--- Comment #3 from Arjun Shankar <arjun.is at lostca dot se> ---
If the code is compiled as C, gcc produces essentially the same code as clang
with some differences in the schedule of instructions:
https://godbolt.org/z/8nsq16Pen
It's when the code is compiled as C++ that gcc does worse:
https://godbolt.org/z/dK8hTEhjr
The difference lies in the front-ends. The C front-end already appears to know
that this is a XOR. testcase.c.004t.original looks like:
return (int) (x < 0 ^ y <= 0);
On the other hand, g++ outputs:
return <retval> = x >= 0 == y <= 0;
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/95185] Failure to optimize specific kind of sign comparison check
2020-05-18 12:05 [Bug tree-optimization/95185] New: Failure to optimize specific kind of sign comparison check gabravier at gmail dot com
` (2 preceding siblings ...)
2021-10-04 23:02 ` arjun.is at lostca dot se
@ 2021-10-04 23:12 ` pinskia at gcc dot gnu.org
2023-06-18 19:24 ` pinskia at gcc dot gnu.org
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-10-04 23:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95185
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=101807
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
related to PR 101807
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/95185] Failure to optimize specific kind of sign comparison check
2020-05-18 12:05 [Bug tree-optimization/95185] New: Failure to optimize specific kind of sign comparison check gabravier at gmail dot com
` (3 preceding siblings ...)
2021-10-04 23:12 ` pinskia at gcc dot gnu.org
@ 2023-06-18 19:24 ` pinskia at gcc dot gnu.org
2023-08-28 20:36 ` pinskia at gcc dot gnu.org
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-18 19:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95185
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
_1 = x_4(D) >= 0;
_2 = y_5(D) <= 0;
_3 = _1 == _2;
Something like:
Prefer ^ over ==
```
(for cmp
(for cmpN
(for neeq
(simplify
(neeq:c (cmp @0 @1) @3
(if (cmpN == inverseof(cmp, TREE_TYPE (type))
(bit_xor (cmpN @0 @1) @3)
)
)
)))
```
This is what clang seems to do rather than any magic around == really.
I do wonder if we should try to expand bool == bool as bool^bool^1 .
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/95185] Failure to optimize specific kind of sign comparison check
2020-05-18 12:05 [Bug tree-optimization/95185] New: Failure to optimize specific kind of sign comparison check gabravier at gmail dot com
` (4 preceding siblings ...)
2023-06-18 19:24 ` pinskia at gcc dot gnu.org
@ 2023-08-28 20:36 ` pinskia at gcc dot gnu.org
2023-08-28 21:08 ` pinskia at gcc dot gnu.org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-28 20:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95185
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pinskia at gcc dot gnu.org
--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 107881 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/95185] Failure to optimize specific kind of sign comparison check
2020-05-18 12:05 [Bug tree-optimization/95185] New: Failure to optimize specific kind of sign comparison check gabravier at gmail dot com
` (5 preceding siblings ...)
2023-08-28 20:36 ` pinskia at gcc dot gnu.org
@ 2023-08-28 21:08 ` pinskia at gcc dot gnu.org
2023-08-29 4:04 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-28 21:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95185
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 #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #5)
>
> Something like:
> Prefer ^ over ==
> ```
> (for cmp
> (for cmpN
> (for neeq
> (simplify
> (neeq:c (cmp @0 @1) @3
> (if (cmpN == inverseof(cmp, TREE_TYPE (type))
> (bit_xor (cmpN @0 @1) @3)
> )
> )
> )))
> ```
Actually we can just do:
```
/* For CMP == b, prefer CMP` ^ b. */
(for neeq (ne eq)
(for cmp (tcc_comparison)
(simplify
(neeq:c (cmp@0 @1 @2) @3)
(bit_xor (bit_not! @0) @3)
)
)
)
```
Since we already have folding of (bit_not cmp) in another place.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/95185] Failure to optimize specific kind of sign comparison check
2020-05-18 12:05 [Bug tree-optimization/95185] New: Failure to optimize specific kind of sign comparison check gabravier at gmail dot com
` (6 preceding siblings ...)
2023-08-28 21:08 ` pinskia at gcc dot gnu.org
@ 2023-08-29 4:04 ` pinskia at gcc dot gnu.org
2023-09-11 22:14 ` [Bug tree-optimization/95185] [11/12/13/14 Regression] " pinskia at gcc dot gnu.org
2024-03-22 14:09 ` law at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-29 4:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95185
--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I have a patch which converts this into:
_1 = x_4(D) < 0;
_2 = y_5(D) <= 0;
_3 = _1 ^ _2;
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/95185] [11/12/13/14 Regression] Failure to optimize specific kind of sign comparison check
2020-05-18 12:05 [Bug tree-optimization/95185] New: Failure to optimize specific kind of sign comparison check gabravier at gmail dot com
` (7 preceding siblings ...)
2023-08-29 4:04 ` pinskia at gcc dot gnu.org
@ 2023-09-11 22:14 ` pinskia at gcc dot gnu.org
2024-03-22 14:09 ` law at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-11 22:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95185
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |NEW
Assignee|pinskia at gcc dot gnu.org |unassigned at gcc dot gnu.org
Keywords| |needs-bisection
Summary|Failure to optimize |[11/12/13/14 Regression]
|specific kind of sign |Failure to optimize
|comparison check |specific kind of sign
| |comparison check
Known to work| |8.5.0
Target Milestone|--- |11.5
Known to fail| |9.1.0
--- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The original testcase is actually a regression.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/95185] [11/12/13/14 Regression] Failure to optimize specific kind of sign comparison check
2020-05-18 12:05 [Bug tree-optimization/95185] New: Failure to optimize specific kind of sign comparison check gabravier at gmail dot com
` (8 preceding siblings ...)
2023-09-11 22:14 ` [Bug tree-optimization/95185] [11/12/13/14 Regression] " pinskia at gcc dot gnu.org
@ 2024-03-22 14:09 ` law at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: law at gcc dot gnu.org @ 2024-03-22 14:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95185
Jeffrey A. Law <law at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
CC| |law at gcc dot gnu.org
^ permalink raw reply [flat|nested] 11+ messages in thread