public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/67057] New: [SH] Use negc to calculate 1-T+const_int
@ 2015-07-29 14:30 olegendo at gcc dot gnu.org
2015-07-29 14:42 ` [Bug target/67057] " olegendo at gcc dot gnu.org
2015-07-29 14:53 ` olegendo at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: olegendo at gcc dot gnu.org @ 2015-07-29 14:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67057
Bug ID: 67057
Summary: [SH] Use negc to calculate 1-T+const_int
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: olegendo at gcc dot gnu.org
Target Milestone: ---
The following
int foo (int a, int b)
{
return ((a & (1 << 25)) ? 5 : 4);
}
compiled with -O2 results in:
mov.l .L4,r1
mov #-1,r0
tst r1,r4
negc r0,r0
rts
add #4,r0 // r0 = 1 - T + 4
// = 5 - T
.L5:
.align 2
.L4:
.long 33554432
The negc insn calculates 0 - reg - T, which can be used to calculate const_int
+ T. In fact, it is already used to calculate 1 - T as a replacement for SH2A
movrt.
The resulting code should look something like this:
mov.l .L4,r1
mov #-5,r0
tst r1,r4
rts
negc r0,r0
Combine is looking for a pattern:
Failed to match this instruction:
(set (reg:SI 162 [ D.1652 ])
(plus:SI (zero_extract:SI (reg:SI 4 r4 [ a ])
(const_int 1 [0x1])
(const_int 25 [0x19]))
(const_int 4 [0x4])))
Which could be implemented with treg_set_expr.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug target/67057] [SH] Use negc to calculate 1-T+const_int
2015-07-29 14:30 [Bug target/67057] New: [SH] Use negc to calculate 1-T+const_int olegendo at gcc dot gnu.org
@ 2015-07-29 14:42 ` olegendo at gcc dot gnu.org
2015-07-29 14:53 ` olegendo at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: olegendo at gcc dot gnu.org @ 2015-07-29 14:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67057
--- Comment #1 from Oleg Endo <olegendo at gcc dot gnu.org> ---
For some cases where T+const_int is calculated, like ...
int foo (int a, int b)
{
return a == b ? 5 : 4;
}
comiled with -O2:
cmp/eq r5,r4
movt r0
rts
add #4,r0
.. the dependency of the comparison and the T bit store can be reduced:
cmp/eq r5,r4
mov #2,r0
rts
addc r0,r0
This works only for even constants.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug target/67057] [SH] Use negc to calculate 1-T+const_int
2015-07-29 14:30 [Bug target/67057] New: [SH] Use negc to calculate 1-T+const_int olegendo at gcc dot gnu.org
2015-07-29 14:42 ` [Bug target/67057] " olegendo at gcc dot gnu.org
@ 2015-07-29 14:53 ` olegendo at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: olegendo at gcc dot gnu.org @ 2015-07-29 14:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67057
--- Comment #2 from Oleg Endo <olegendo at gcc dot gnu.org> ---
(In reply to Oleg Endo from comment #0)
> Combine is looking for a pattern:
>
> Failed to match this instruction:
> (set (reg:SI 162 [ D.1652 ])
> (plus:SI (zero_extract:SI (reg:SI 4 r4 [ a ])
> (const_int 1 [0x1])
> (const_int 25 [0x19]))
> (const_int 4 [0x4])))
>
> Which could be implemented with treg_set_expr.
In this case, the treg_set_expr should be only matched if it will expand into a
negating T bit store. For that a new predicate "neg_treg_set_expr" should be
added. sh_recog_treg_set_expr should get an additional parameter whether it
should match positive, negative or both forms.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-07-29 14:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-29 14:30 [Bug target/67057] New: [SH] Use negc to calculate 1-T+const_int olegendo at gcc dot gnu.org
2015-07-29 14:42 ` [Bug target/67057] " olegendo at gcc dot gnu.org
2015-07-29 14:53 ` 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).