public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/102872] New: If statement is always false but not figured out at gimple level
@ 2021-10-21 8:25 pinskia at gcc dot gnu.org
2021-10-21 8:28 ` [Bug tree-optimization/102872] " pinskia at gcc dot gnu.org
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-10-21 8:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102872
Bug ID: 102872
Summary: If statement is always false but not figured out at
gimple level
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Keywords: missed-optimization, TREE
Severity: enhancement
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
Take:
void foo(void);
static int a, b;
int main() {
for (; a; ++a) {
unsigned short d = a;
if (!(b | d) && d)
foo();
}
}
---- CUT ---
This is the reduced testcase of PR 102703 but without the store to a static
variable which then was removed.
In VRP1 we have:
d_10 = (short unsigned int) a.3_5;
_9 = a.3_5 & 65535;
if (_9 == 0)
goto <bb 4>; [50.00%]
else
goto <bb 6>; [50.00%]
<bb 4> [local count: 477815112]:
if (d_10 != 0)
goto <bb 5>; [33.00%]
else
goto <bb 6>; [67.00%]
<bb 5> [local count: 157678986]:
foo ();
_9 and d_10 have the same value though different types.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/102872] If statement is always false but not figured out at gimple level
2021-10-21 8:25 [Bug tree-optimization/102872] New: If statement is always false but not figured out at gimple level pinskia at gcc dot gnu.org
@ 2021-10-21 8:28 ` pinskia at gcc dot gnu.org
2021-10-21 8:58 ` rguenth at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-10-21 8:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102872
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note this does not get optimized at the rtl level on all targets either, e.g.
aarch64 we get:
tst w0, 65535
and w0, w0, 65535
ccmp w0, 0, 4, eq
beq .L3
bl foo
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/102872] If statement is always false but not figured out at gimple level
2021-10-21 8:25 [Bug tree-optimization/102872] New: If statement is always false but not figured out at gimple level pinskia at gcc dot gnu.org
2021-10-21 8:28 ` [Bug tree-optimization/102872] " pinskia at gcc dot gnu.org
@ 2021-10-21 8:58 ` rguenth at gcc dot gnu.org
2021-11-20 8:59 ` pinskia at gcc dot gnu.org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-10-21 8:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102872
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
Last reconfirmed| |2021-10-21
CC| |amacleod at redhat dot com,
| |rguenth at gcc dot gnu.org
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed. I wonder if the relation oracle could be extended to handle this
though there's the usual caveat that _9 and d_10 are not dependent on each
other but only are indirectly related through a.3_5.
d_10 = (short unsigned int) a.3_5;
_9 = a.3_5 & 65535;
if (_9 == 0)
Here VN could be teached to look for (short unsigned int) a.3_5 when
seeing a.3_5 & 65535 and CSE it as (short signed int) d_10 (but then
I think we might fold that back).
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/102872] If statement is always false but not figured out at gimple level
2021-10-21 8:25 [Bug tree-optimization/102872] New: If statement is always false but not figured out at gimple level pinskia at gcc dot gnu.org
2021-10-21 8:28 ` [Bug tree-optimization/102872] " pinskia at gcc dot gnu.org
2021-10-21 8:58 ` rguenth at gcc dot gnu.org
@ 2021-11-20 8:59 ` pinskia at gcc dot gnu.org
2021-11-22 11:17 ` rguenth at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-20 8:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102872
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I wonder if we should just do this:
(for neeq (ne eq)
(simplify
(neeq (convert:s @0) integer_zerop@1)
(with
{
tree inside_type = TREE_TYPE (@0);
tree outer_type = TREE_TYPE (@1);
}
(if (TYPE_PRECISION (inside_type) > TYPE_PRECISION (outer_type))
(neeq (bit_and @0
{ wide_int_to_tree (type0,
wi::mask (TYPE_PRECISION (inside_type),
false,
TYPE_PRECISION (outer_type))); })
{ build_zero_cst (inside_type); })))))
)
Or does the bit_and to a convert make better sense? I don't care either way
really but it would be a good idea to chose one or the other really.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/102872] If statement is always false but not figured out at gimple level
2021-10-21 8:25 [Bug tree-optimization/102872] New: If statement is always false but not figured out at gimple level pinskia at gcc dot gnu.org
` (2 preceding siblings ...)
2021-11-20 8:59 ` pinskia at gcc dot gnu.org
@ 2021-11-22 11:17 ` rguenth at gcc dot gnu.org
2022-10-13 15:29 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-11-22 11:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102872
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
ifcombine makes
optimizing two comparisons to _13
Merging blocks 3 and 4
to
<bb 3> [local count: 955630225]:
d_10 = (short unsigned int) a.3_5;
_9 = a.3_5 & 65535;
_2 = d_10 != 0;
_1 = _9 == 0;
_13 = _1 & _2;
if (_13 != 0)
so I wonder if we can simplify that somehow. It looks like this could be
simplified to (a & 0xffff0000) != 0?
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/102872] If statement is always false but not figured out at gimple level
2021-10-21 8:25 [Bug tree-optimization/102872] New: If statement is always false but not figured out at gimple level pinskia at gcc dot gnu.org
` (3 preceding siblings ...)
2021-11-22 11:17 ` rguenth at gcc dot gnu.org
@ 2022-10-13 15:29 ` cvs-commit at gcc dot gnu.org
2022-10-13 17:02 ` amacleod at redhat dot com
2022-11-28 22:41 ` pinskia at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-10-13 15:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102872
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Andrew Macleod <amacleod@gcc.gnu.org>:
https://gcc.gnu.org/g:6cc3394507a2303a18891d34222c53f679256c37
commit r13-3281-g6cc3394507a2303a18891d34222c53f679256c37
Author: Andrew MacLeod <amacleod@redhat.com>
Date: Wed Oct 5 10:42:07 2022 -0400
propagate partial equivs in the cache.
Adjust on-entry cache propagation to look for and propagate both full
and partial equivalences.
gcc/
PR tree-optimization/102540
PR tree-optimization/102872
* gimple-range-cache.cc (ranger_cache::fill_block_cache):
Handle partial equivs.
(ranger_cache::range_from_dom): Cleanup dump output.
gcc/testsuite/
* gcc.dg/pr102540.c: New.
* gcc.dg/pr102872.c: New.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/102872] If statement is always false but not figured out at gimple level
2021-10-21 8:25 [Bug tree-optimization/102872] New: If statement is always false but not figured out at gimple level pinskia at gcc dot gnu.org
` (4 preceding siblings ...)
2022-10-13 15:29 ` cvs-commit at gcc dot gnu.org
@ 2022-10-13 17:02 ` amacleod at redhat dot com
2022-11-28 22:41 ` pinskia at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: amacleod at redhat dot com @ 2022-10-13 17:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102872
Andrew Macleod <amacleod at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|NEW |RESOLVED
--- Comment #6 from Andrew Macleod <amacleod at redhat dot com> ---
fixed.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/102872] If statement is always false but not figured out at gimple level
2021-10-21 8:25 [Bug tree-optimization/102872] New: If statement is always false but not figured out at gimple level pinskia at gcc dot gnu.org
` (5 preceding siblings ...)
2022-10-13 17:02 ` amacleod at redhat dot com
@ 2022-11-28 22:41 ` pinskia at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-28 22:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102872
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |13.0
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2022-11-28 22:41 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-21 8:25 [Bug tree-optimization/102872] New: If statement is always false but not figured out at gimple level pinskia at gcc dot gnu.org
2021-10-21 8:28 ` [Bug tree-optimization/102872] " pinskia at gcc dot gnu.org
2021-10-21 8:58 ` rguenth at gcc dot gnu.org
2021-11-20 8:59 ` pinskia at gcc dot gnu.org
2021-11-22 11:17 ` rguenth at gcc dot gnu.org
2022-10-13 15:29 ` cvs-commit at gcc dot gnu.org
2022-10-13 17:02 ` amacleod at redhat dot com
2022-11-28 22:41 ` pinskia 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).