public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/51780] New: Missed optimization for ==/!= comparison
@ 2012-01-07 10:46 ktietz at gcc dot gnu.org
2021-08-15 22:09 ` [Bug tree-optimization/51780] " pinskia at gcc dot gnu.org
2021-08-15 22:16 ` pinskia at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: ktietz at gcc dot gnu.org @ 2012-01-07 10:46 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51780
Bug #: 51780
Summary: Missed optimization for ==/!= comparison
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: ktietz@gcc.gnu.org
Target: *-*-*
Hi,
optimization misses to eliminate addition for 'b' in following code:
extern unsigned int ar[256];
int foo (int a, unsigned int b)
{
int c = ar[a] + b;
int d = (int) b;
return c != d;
}
compiled this code with -O2 we get tree-optimized as follwing:
;; Function foo (foo, funcdef_no=0, decl_uid=1600, cgraph_uid=0)
foo (int a, unsigned int b)
{
int d;
int c;
_Bool D.2717;
int D.2716;
unsigned int D.2715;
unsigned int D.2714;
<bb 2>:
D.2714_2 = ar[a_1(D)];
D.2715_4 = D.2714_2 + b_3(D);
c_5 = (int) D.2715_4;
d_6 = (int) b_3(D);
D.2717_7 = c_5 != d_6;
D.2716_8 = (int) D.2717_7;
<L0>:
return D.2716_8;
}
but optimized variant should be:
;; Function foo (foo, funcdef_no=0, decl_uid=1709, cgraph_uid=0)
foo (int a, unsigned int b)
{
_Bool D.1717;
int D.1716;
unsigned int D.1714;
<bb 2>:
D.1714_2 = ar[a_1(D)];
D.1717_7 = D.1714_2 != 0;
D.1716_8 = (int) D.1717_7;
return D.1716_8;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/51780] Missed optimization for ==/!= comparison
2012-01-07 10:46 [Bug tree-optimization/51780] New: Missed optimization for ==/!= comparison ktietz at gcc dot gnu.org
@ 2021-08-15 22:09 ` pinskia at gcc dot gnu.org
2021-08-15 22:16 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-15 22:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51780
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to work| |8.1.0
Known to fail| |7.5.0
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
_1 = ar[a_4(D)];
_2 = _1 != 0;
_6 = (int) _2;
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/51780] Missed optimization for ==/!= comparison
2012-01-07 10:46 [Bug tree-optimization/51780] New: Missed optimization for ==/!= comparison ktietz at gcc dot gnu.org
2021-08-15 22:09 ` [Bug tree-optimization/51780] " pinskia at gcc dot gnu.org
@ 2021-08-15 22:16 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-15 22:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51780
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |8.0
Resolution|--- |FIXED
Status|NEW |RESOLVED
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed with r8-3771.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-08-15 22:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-07 10:46 [Bug tree-optimization/51780] New: Missed optimization for ==/!= comparison ktietz at gcc dot gnu.org
2021-08-15 22:09 ` [Bug tree-optimization/51780] " pinskia at gcc dot gnu.org
2021-08-15 22:16 ` 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).