public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug optimization/14752] New: [tree-ssa] "~a" should be changed to "a" if used in the condition of an if statement
@ 2004-03-27 14:45 kazu at cs dot umass dot edu
2004-03-27 15:45 ` [Bug optimization/14752] " pinskia at gcc dot gnu dot org
` (5 more replies)
0 siblings, 6 replies; 12+ messages in thread
From: kazu at cs dot umass dot edu @ 2004-03-27 14:45 UTC (permalink / raw)
To: gcc-bugs
Consider:
void bar (void);
void
foo (unsigned int a)
{
if (((a >> 2) & 1))
bar ();
}
void
baz (unsigned int a)
{
if (((~a >> 2) & 1))
bar ();
}
tree-ssa optimizers cannot absorb "~" in "~a" by swapping then and else clauses.
Here is the last tree in SSA form.
;; Function foo (foo)
foo (a)
{
_Bool T.2;
unsigned int T.1;
unsigned int T.0;
<bb 0>:
T.0_2 = a_1 >> 2;
T.1_3 = T.0_2 & 1;
T.2_4 = (_Bool)T.1_3;
if (T.2_4) goto <L0>; else goto <L1>;
<L0>:;
bar () [tail call];
<L1>:;
return;
}
;; Function baz (baz)
baz (a)
{
_Bool T.6;
unsigned int T.5;
unsigned int T.4;
unsigned int T.3;
<bb 0>:
T.3_2 = ~a_1; <- we could remove this "~" by ...
T.4_3 = T.3_2 >> 2;
T.5_4 = T.4_3 & 1;
T.6_5 = (_Bool)T.5_4;
if (T.6_5) goto <L0>; else goto <L1>; <- flipping the labels
<L0>:;
bar () [tail call];
<L1>:;
return;
}
The combiner can atually take care of this, but we can reduce initial rtl
if we remove "~".
--
Summary: [tree-ssa] "~a" should be changed to "a" if used in the
condition of an if statement
Product: gcc
Version: tree-ssa
Status: UNCONFIRMED
Keywords: pessimizes-code
Severity: enhancement
Priority: P2
Component: optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: kazu at cs dot umass dot edu
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14752
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug optimization/14752] [tree-ssa] "~a" should be changed to "a" if used in the condition of an if statement
2004-03-27 14:45 [Bug optimization/14752] New: [tree-ssa] "~a" should be changed to "a" if used in the condition of an if statement kazu at cs dot umass dot edu
@ 2004-03-27 15:45 ` pinskia at gcc dot gnu dot org
2004-04-04 7:34 ` pinskia at gcc dot gnu dot org
` (4 subsequent siblings)
5 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-03-27 15:45 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-03-27 15:45 -------
Confirmed.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Last reconfirmed|0000-00-00 00:00:00 |2004-03-27 15:45:24
date| |
Target Milestone|--- |tree-ssa
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14752
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug optimization/14752] [tree-ssa] "~a" should be changed to "a" if used in the condition of an if statement
2004-03-27 14:45 [Bug optimization/14752] New: [tree-ssa] "~a" should be changed to "a" if used in the condition of an if statement kazu at cs dot umass dot edu
2004-03-27 15:45 ` [Bug optimization/14752] " pinskia at gcc dot gnu dot org
@ 2004-04-04 7:34 ` pinskia at gcc dot gnu dot org
2004-04-05 23:36 ` kazu at cs dot umass dot edu
` (3 subsequent siblings)
5 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-04-04 7:34 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-04-04 07:34 -------
Note the following is removed by cast already but this does not help this case at all:
T.6_5 = (_Bool)T.5_4;
--
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed|2004-03-27 15:45:24 |2004-04-04 07:34:41
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14752
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug optimization/14752] [tree-ssa] "~a" should be changed to "a" if used in the condition of an if statement
2004-03-27 14:45 [Bug optimization/14752] New: [tree-ssa] "~a" should be changed to "a" if used in the condition of an if statement kazu at cs dot umass dot edu
2004-03-27 15:45 ` [Bug optimization/14752] " pinskia at gcc dot gnu dot org
2004-04-04 7:34 ` pinskia at gcc dot gnu dot org
@ 2004-04-05 23:36 ` kazu at cs dot umass dot edu
2004-05-15 23:36 ` [Bug tree-optimization/14752] " kazu at cs dot umass dot edu
` (2 subsequent siblings)
5 siblings, 0 replies; 12+ messages in thread
From: kazu at cs dot umass dot edu @ 2004-04-05 23:36 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From kazu at cs dot umass dot edu 2004-04-05 23:36 -------
Note that "~" may be expressed using "^ 1".
--
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |TREE
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14752
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/14752] [tree-ssa] "~a" should be changed to "a" if used in the condition of an if statement
2004-03-27 14:45 [Bug optimization/14752] New: [tree-ssa] "~a" should be changed to "a" if used in the condition of an if statement kazu at cs dot umass dot edu
` (2 preceding siblings ...)
2004-04-05 23:36 ` kazu at cs dot umass dot edu
@ 2004-05-15 23:36 ` kazu at cs dot umass dot edu
2004-05-24 20:31 ` pinskia at gcc dot gnu dot org
2005-02-18 12:31 ` phython at gcc dot gnu dot org
5 siblings, 0 replies; 12+ messages in thread
From: kazu at cs dot umass dot edu @ 2004-05-15 23:36 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From kazu at cs dot umass dot edu 2004-05-15 11:55 -------
As of today, the last tree-ssa form looks like:
;; Function foo (foo)
foo (a)
{
_Bool T.2;
unsigned int T.1;
unsigned int T.0;
<bb 0>:
T.0_2 = a_1 >> 2;
T.1_3 = T.0_2 & 1;
if (T.1_3 != 0) goto <L0>; else goto <L1>;
<L0>:;
bar () [tail call];
<L1>:;
return;
}
;; Function baz (baz)
baz (a)
{
_Bool T.6;
unsigned int T.5;
unsigned int T.4;
unsigned int T.3;
<bb 0>:
T.3_2 = ~a_1;
T.4_3 = T.3_2 >> 2;
T.5_4 = T.4_3 & 1;
if (T.5_4 != 0) goto <L0>; else goto <L1>;
<L0>:;
bar () [tail call];
<L1>:;
return;
}
Note that the casts to _Bool are gone.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14752
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/14752] [tree-ssa] "~a" should be changed to "a" if used in the condition of an if statement
2004-03-27 14:45 [Bug optimization/14752] New: [tree-ssa] "~a" should be changed to "a" if used in the condition of an if statement kazu at cs dot umass dot edu
` (3 preceding siblings ...)
2004-05-15 23:36 ` [Bug tree-optimization/14752] " kazu at cs dot umass dot edu
@ 2004-05-24 20:31 ` pinskia at gcc dot gnu dot org
2005-02-18 12:31 ` phython at gcc dot gnu dot org
5 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-24 20:31 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|3.5.0 |---
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14752
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/14752] [tree-ssa] "~a" should be changed to "a" if used in the condition of an if statement
2004-03-27 14:45 [Bug optimization/14752] New: [tree-ssa] "~a" should be changed to "a" if used in the condition of an if statement kazu at cs dot umass dot edu
` (4 preceding siblings ...)
2004-05-24 20:31 ` pinskia at gcc dot gnu dot org
@ 2005-02-18 12:31 ` phython at gcc dot gnu dot org
5 siblings, 0 replies; 12+ messages in thread
From: phython at gcc dot gnu dot org @ 2005-02-18 12:31 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From phython at gcc dot gnu dot org 2005-02-18 00:53 -------
Shouldn't comment #3 say ~a is the same as a ^ -1?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14752
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/14752] [tree-ssa] "~a" should be changed to "a" if used in the condition of an if statement
[not found] <bug-14752-4@http.gcc.gnu.org/bugzilla/>
@ 2014-10-31 4:02 ` pinskia at gcc dot gnu.org
0 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2014-10-31 4:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=14752
Bug 14752 depends on bug 15459, which changed state.
Bug 15459 Summary: [meta-bug] there should be a tree combiner like the rtl one
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=15459
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/14752] [tree-ssa] "~a" should be changed to "a" if used in the condition of an if statement
[not found] <bug-14752-5009@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2006-02-28 21:40 ` sayle at gcc dot gnu dot org
@ 2006-02-28 22:20 ` pinskia at gcc dot gnu dot org
3 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-02-28 22:20 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from pinskia at gcc dot gnu dot org 2006-02-28 22:19 -------
Fixed.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.2.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14752
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/14752] [tree-ssa] "~a" should be changed to "a" if used in the condition of an if statement
[not found] <bug-14752-5009@http.gcc.gnu.org/bugzilla/>
2006-02-28 18:24 ` pinskia at gcc dot gnu dot org
2006-02-28 18:28 ` patchapp at dberlin dot org
@ 2006-02-28 21:40 ` sayle at gcc dot gnu dot org
2006-02-28 22:20 ` pinskia at gcc dot gnu dot org
3 siblings, 0 replies; 12+ messages in thread
From: sayle at gcc dot gnu dot org @ 2006-02-28 21:40 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from sayle at gcc dot gnu dot org 2006-02-28 21:31 -------
Subject: Bug 14752
Author: sayle
Date: Tue Feb 28 21:31:29 2006
New Revision: 111575
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=111575
Log:
PR middle-end/14752
* c-common.c (c_common_truthvalue_conversion) <MINUS_EXPR,
BIT_XOR_EXPR, BIT_AND_EXPR>: Delete. Let fold optimize these
cases via the construction of "expr != 0".
* gcc.dg/fold-eqandshift-2.c: New test case.
Added:
trunk/gcc/testsuite/gcc.dg/fold-eqandshift-2.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/c-common.c
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14752
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/14752] [tree-ssa] "~a" should be changed to "a" if used in the condition of an if statement
[not found] <bug-14752-5009@http.gcc.gnu.org/bugzilla/>
2006-02-28 18:24 ` pinskia at gcc dot gnu dot org
@ 2006-02-28 18:28 ` patchapp at dberlin dot org
2006-02-28 21:40 ` sayle at gcc dot gnu dot org
2006-02-28 22:20 ` pinskia at gcc dot gnu dot org
3 siblings, 0 replies; 12+ messages in thread
From: patchapp at dberlin dot org @ 2006-02-28 18:28 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from patchapp at dberlin dot org 2006-02-28 18:23 -------
Subject: Bug number PR14752
A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is
http://gcc.gnu.org/ml/gcc-patches/2006-02/msg02034.html
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14752
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/14752] [tree-ssa] "~a" should be changed to "a" if used in the condition of an if statement
[not found] <bug-14752-5009@http.gcc.gnu.org/bugzilla/>
@ 2006-02-28 18:24 ` pinskia at gcc dot gnu dot org
2006-02-28 18:28 ` patchapp at dberlin dot org
` (2 subsequent siblings)
3 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-02-28 18:24 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from pinskia at gcc dot gnu dot org 2006-02-28 18:23 -------
Patch here:
http://gcc.gnu.org/ml/gcc-patches/2006-02/msg02034.html
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
URL| |http://gcc.gnu.org/ml/gcc-
| |patches/2006-
| |02/msg02034.html
Keywords| |patch
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14752
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2014-10-31 4:02 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-27 14:45 [Bug optimization/14752] New: [tree-ssa] "~a" should be changed to "a" if used in the condition of an if statement kazu at cs dot umass dot edu
2004-03-27 15:45 ` [Bug optimization/14752] " pinskia at gcc dot gnu dot org
2004-04-04 7:34 ` pinskia at gcc dot gnu dot org
2004-04-05 23:36 ` kazu at cs dot umass dot edu
2004-05-15 23:36 ` [Bug tree-optimization/14752] " kazu at cs dot umass dot edu
2004-05-24 20:31 ` pinskia at gcc dot gnu dot org
2005-02-18 12:31 ` phython at gcc dot gnu dot org
[not found] <bug-14752-5009@http.gcc.gnu.org/bugzilla/>
2006-02-28 18:24 ` pinskia at gcc dot gnu dot org
2006-02-28 18:28 ` patchapp at dberlin dot org
2006-02-28 21:40 ` sayle at gcc dot gnu dot org
2006-02-28 22:20 ` pinskia at gcc dot gnu dot org
[not found] <bug-14752-4@http.gcc.gnu.org/bugzilla/>
2014-10-31 4:02 ` 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).