public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Move insn out of the way
@ 2011-08-10 11:20 Paulo J. Matos
  2011-08-10 11:40 ` Richard Guenther
  0 siblings, 1 reply; 15+ messages in thread
From: Paulo J. Matos @ 2011-08-10 11:20 UTC (permalink / raw)
  To: gcc

Hi,

I am having a size optimisation issue with GCC-4.6.1.
The problem boils down to the fact that I have no idea on the best way 
to hint to GCC that a given insn would make more sense someplace else.

The C code is simple:
int16_t mask(uint32_t a)
{
     return (x & a) == a;
}

int16_t is QImode and uint32_t is HImode.
After combine the insn chain (which is unmodified all the way to ira) is 
(in simplified form):
regQI 27 <- regQI AH [a]
regQI 28 <- regQI AL [a+1]
regQI AL <- andQI(regQI 28, memQI(symbolrefQI(x) + 1))
regQI AH <- andQI(regQI 27, memQI(symbolrefQI(x))
regQI 30 <- regQI AL
regQI 29 <- regQI AH
regQI 24 <- 1
if regQI 29 != regQI 27
    goto labelref 20
if regQI 30 != regQI 28
    goto labelref 20
goto labelref 22
labelref 20
regQI 24 <- 0
labelref 22
regQI AL <- regQI 24

The problem resides in `regQI 24 <- 1' being before the jumps.
Since regQI 24 is going to AL, IRA decides to allocate regQI 24 to AL, 
which creates loads of conflicts and reloads. If that same insn would be 
moved to after the jumps and before the `goto labelref 22' then all 
would be fine cause by then regs 27, 28, 29, 30 are dead.

It's obviously hard to point to a solution but I was wondering if 
there's a way to hint to GCC that moving an insn might help the code 
issue. Or if I should look into a why an existing pass is not already 
doing that.

Cheers,

-- 
PMatos

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2011-08-12 16:12 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-10 11:20 Move insn out of the way Paulo J. Matos
2011-08-10 11:40 ` Richard Guenther
2011-08-10 11:42   ` Richard Guenther
2011-08-10 13:55     ` Paulo J. Matos
     [not found]       ` <4E431BD8.8060705@redhat.com>
2011-08-11  8:12         ` Paulo J. Matos
2011-08-11  8:49           ` Richard Guenther
2011-08-11 14:27             ` Vladimir Makarov
2011-08-12 10:01               ` Paulo J. Matos
2011-08-12 14:22                 ` Vladimir Makarov
2011-08-12 15:06                   ` Paulo J. Matos
2011-08-12 16:12                 ` Jeff Law
2011-08-11 12:22         ` Paulo J. Matos
2011-08-10 13:46   ` Paulo J. Matos
2011-08-10 13:51     ` Richard Guenther
2011-08-10 14:14       ` Paulo J. Matos

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).