public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/61051] New: Duplicated instructions in both conditional branches
@ 2014-05-04 4:15 carrot at google dot com
2015-03-25 4:24 ` [Bug target/61051] " msebor at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: carrot at google dot com @ 2014-05-04 4:15 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61051
Bug ID: 61051
Summary: Duplicated instructions in both conditional branches
Product: gcc
Version: 4.10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: carrot at google dot com
Target: powerpc64le-grtev4-linux-gnu
Source code:
extern int* foo1 ( long* );
extern int *foo2 ( long *, long *);
extern void foo3 (long, long);
void bar()
{
long d, f, x, s, r;
int *p;
d = 1;
if (foo1(&r))
{
p = foo2( &d, &x);
if( x != *p )
s = 1;
else
s = 2;
if( r > 0 )
f = 1 + d;
else
f = d;
foo3 (f, d);
*p = s;
}
}
Compile it with options -O2 -m64 -mcpu=power8, gcc generates:
bar:
0: addis 2,12,.TOC.-0b@ha
addi 2,2,.TOC.-0b@l
.localentry bar,.-bar
mflr 0
std 30,-16(1)
std 31,-8(1)
li 9,1
std 0,16(1)
stdu 1,-80(1)
addi 3,1,32
std 9,48(1)
bl foo1
nop
cmpdi 7,3,0
beq 7,.L1
addi 3,1,48
addi 4,1,40
bl foo2
nop
ld 10,40(1)
li 30,1
lwa 9,0(3)
mr 31,3
cmpd 7,9,10
beq 7,.L12 // C
ld 9,32(1) // A1
cmpdi 7,9,0 // A2
ble 7,.L4
.L13:
ld 4,48(1)
addi 3,4,1
.L5:
bl foo3
nop
stw 30,0(31)
.L1:
addi 1,1,80
ld 0,16(1)
ld 30,-16(1)
ld 31,-8(1)
mtlr 0
blr
.p2align 4,,15
.L12:
ld 9,32(1) // B1
li 30,2
cmpdi 7,9,0 // B2
bgt 7,.L13
.L4:
ld 3,48(1)
mr 4,3
b .L5
.long 0
.byte 0,0,0,1,128,2,0,0
.size bar,.-bar
Instruction C is a conditional branch. In both branches A1 and B1 are same
instructions, they can be moved to before C. If we use a different conditional
register, instructions A2 and B2 can also be moved before C.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/61051] Duplicated instructions in both conditional branches
2014-05-04 4:15 [Bug target/61051] New: Duplicated instructions in both conditional branches carrot at google dot com
@ 2015-03-25 4:24 ` msebor at gcc dot gnu.org
2015-03-25 8:45 ` steven at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: msebor at gcc dot gnu.org @ 2015-03-25 4:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61051
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target|powerpc64le-grtev4-linux-gn |powerpc64*-*-linux-*
|u |
CC| |msebor at gcc dot gnu.org
--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
The latest trunk still emits code that's comparable to the assembly in the
Description, both on powerpc64le and powerpc64.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/61051] Duplicated instructions in both conditional branches
2014-05-04 4:15 [Bug target/61051] New: Duplicated instructions in both conditional branches carrot at google dot com
2015-03-25 4:24 ` [Bug target/61051] " msebor at gcc dot gnu.org
@ 2015-03-25 8:45 ` steven at gcc dot gnu.org
2021-07-18 21:09 ` [Bug tree-optimization/61051] " pinskia at gcc dot gnu.org
2021-07-18 21:12 ` pinskia at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: steven at gcc dot gnu.org @ 2015-03-25 8:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61051
Steven Bosscher <steven at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |WAITING
Last reconfirmed| |2015-03-25
Ever confirmed|0 |1
--- Comment #2 from Steven Bosscher <steven at gcc dot gnu.org> ---
This is code hoisting. That's not performed at -O2. Try -Os.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/61051] Duplicated instructions in both conditional branches
2014-05-04 4:15 [Bug target/61051] New: Duplicated instructions in both conditional branches carrot at google dot com
2015-03-25 4:24 ` [Bug target/61051] " msebor at gcc dot gnu.org
2015-03-25 8:45 ` steven at gcc dot gnu.org
@ 2021-07-18 21:09 ` pinskia at gcc dot gnu.org
2021-07-18 21:12 ` pinskia at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-18 21:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61051
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|target |tree-optimization
Status|WAITING |RESOLVED
Resolution|--- |FIXED
Target Milestone|--- |10.0
Keywords| |missed-optimization
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed on the trunk:
x.0_4 = x;
if (_3 != x.0_4)
goto <bb 5>; [66.00%]
else
goto <bb 4>; [34.00%]
<bb 4> [local count: 195204118]:
<bb 5> [local count: 574129753]:
# prephitmp_24 = PHI <1(3), 2(4)>
r.1_5 = r;
pretmp_26 = d;
if (r.1_5 > 0)
goto <bb 6>; [59.00%]
else
goto <bb 7>; [41.00%]
<bb 6> [local count: 338736556]:
f_18 = pretmp_26 + 1;
<bb 7> [local count: 574129754]:
# f_9 = PHI <f_18(6), pretmp_26(5)>
I think it has been fixed in since at least GCC 10 even.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/61051] Duplicated instructions in both conditional branches
2014-05-04 4:15 [Bug target/61051] New: Duplicated instructions in both conditional branches carrot at google dot com
` (2 preceding siblings ...)
2021-07-18 21:09 ` [Bug tree-optimization/61051] " pinskia at gcc dot gnu.org
@ 2021-07-18 21:12 ` pinskia at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-18 21:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61051
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|10.0 |7.0
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Rather since GCC 7.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-07-18 21:12 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-04 4:15 [Bug target/61051] New: Duplicated instructions in both conditional branches carrot at google dot com
2015-03-25 4:24 ` [Bug target/61051] " msebor at gcc dot gnu.org
2015-03-25 8:45 ` steven at gcc dot gnu.org
2021-07-18 21:09 ` [Bug tree-optimization/61051] " pinskia at gcc dot gnu.org
2021-07-18 21:12 ` 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).