public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/51697] New: SH Target: Inefficient DImode comparisons for -Os
@ 2011-12-29 0:35 oleg.endo@t-online.de
2012-04-12 6:57 ` [Bug target/51697] " olegendo at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: oleg.endo@t-online.de @ 2011-12-29 0:35 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51697
Bug #: 51697
Summary: SH Target: Inefficient DImode comparisons for -Os
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: target
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: oleg.endo@t-online.de
CC: kkojima@gcc.gnu.org
Target: sh*-*-*
For -Os and everything but -m1 DImode comparisons are not optimized properly
which results in redundant SImode comparisons, producing code worse than for
-O1.
A reduced example:
int test_0 (long long* x)
{
return *x & 0xFFFFFFFF ? -20 : -40;
}
-Os -m2/-m3/-m4:
mov #0,r2 ! 55 movsi_ie/3 [length = 2]
tst r2,r2 ! 57 cmpeqsi_t/1 [length = 2]
bf/s .L12 ! 58 branch_false [length = 2]
mov.l @(4,r4),r3 ! 12 movsi_ie/7 [length = 2]
tst r3,r3 ! 59 cmpeqsi_t/1 [length = 2]
.L12:
bt/s .L11 ! 14 branch_true [length = 2]
mov #-40,r0 ! 5 movsi_ie/3 [length = 2]
mov #-20,r0 ! 4 movsi_ie/3 [length = 2]
.L11:
rts
nop ! 65 *return_i [length = 4]
-Os -m1:
-O2 -m4:
mov.l @(4,r4),r1 ! 10 movsi_i/5 [length = 2]
mov #-40,r0 ! 5 movsi_i/3 [length = 2]
tst r1,r1 ! 15 cmpeqsi_t/1 [length = 2]
bt .L7 ! 16 branch_true [length = 2]
mov #-20,r0 ! 4 movsi_i/3 [length = 2]
.L7:
rts
nop ! 61 *return_i [length = 4]
-O1 -m4:
mov.l @(4,r4),r1 ! 10 movsi_ie/7 [length = 2]
tst r1,r1 ! 17 cmpeqsi_t/1 [length = 2]
bt/s .L6 ! 18 branch_true [length = 2]
mov #-40,r0 ! 5 movsi_ie/3 [length = 2]
mov #-20,r0 ! 4 movsi_ie/3 [length = 2]
.L6:
rts
nop ! 62 *return_i [length = 4]
Another example would be:
int test_2 (unsigned long long x)
{
return x >= 0x100000000LL ? -20 : -40;
}
-Os -m2/-m3/-m4:
mov #0,r2 ! 48 movsi_ie/3 [length = 2]
mov #-1,r3 ! 49 movsi_ie/3 [length = 2]
cmp/eq r2,r4 ! 9 cmpgtudi_t [length = 8]
bf/s .Ldi67
cmp/hi r2,r4
cmp/hi r3,r5
.Ldi67:
bf/s .L16 ! 10 branch_false [length = 2]
mov #-40,r0 ! 5 movsi_ie/3 [length = 2]
mov #-20,r0 ! 4 movsi_ie/3 [length = 2]
.L16:
rts
nop ! 52 *return_i [length = 4]
-Os -m1:
tst r4,r4 ! 9 cmpeqsi_t/1 [length = 2]
mov #-20,r0 ! 4 movsi_i/3 [length = 2]
bf .L12 ! 10 branch_false [length = 2]
mov #-40,r0 ! 5 movsi_i/3 [length = 2]
.L12:
rts
nop ! 56 *return_i [length = 4]
The problem does not appear for -m1, only for -Os and -m2*, -m3*, -m4*.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-12-08 22:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-29 0:35 [Bug target/51697] New: SH Target: Inefficient DImode comparisons for -Os oleg.endo@t-online.de
2012-04-12 6:57 ` [Bug target/51697] " olegendo at gcc dot gnu.org
2013-12-08 22:16 ` olegendo at gcc dot gnu.org
2013-12-08 22:22 ` olegendo 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).