This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Use of FLAGS_REGNUM clashes with generates insn
On Fri, 23 Sep 2011 09:30:48 -0400, amylaar wrote:
> Hiding the flags register would mean it is not represented in the rtl at
> all. You can have combined compare-branch instructions. Of course,
> going that route would mean that the model you present to GCC is even
> further from the hardware than one that uses cc0.
>
Got it! That seems that it would go against the whole point of replacing
cc0 for CC_REGNUM in my specific case. Oh well...
>> What I currently have in mind is to have a backend macro listing all
>> the move for which a move clobber CC_REG, then whenever GCC generates a
>> move, it queries the macro to know if the move requires clobbering and
>> emits the clobber if required. However, I am unsure how deep the rabbit
>> hole goes.
>
> Oh, so you do have variants that can do without the clobber.
Actually I don't... My explanation was supposed to be referring to a
general solution. In my case, the macro would list all moves since all
moves clobber CC.
> If you can
> make all the reloads without introducing explicit flag clobbers, that it
> should work.
Unfortunately I can't.
> But you can't just pull a flag clobber out of thin air.
Understood.
> You should have
> some way to generate valid code when the flags register is unavailable /
> must be saved. Then you can use peephole2 to add flag clobbers where
> the flags register is available.
>
> Or you can use machine_dependent_reorg or another machine-specific pass
> inserted with the pass manager to rewrite clobber-free instructions into
> ones that have a hardware equivalent; but you must make sure that your
> data flow remains sound in the process.
I think your last suggestion of having a pass to rewrite the clobber free
instructions into one with a hardware equivalent seems the one to go for
me.
Thanks for the suggestions,
--
PMatos