[cond-optab] remove sync_compare_and_swap_cc optab

H.J. Lu hjl.tools@gmail.com
Mon Aug 16 01:25:00 GMT 2010


On Wed, Mar 11, 2009 at 8:25 AM, Paolo Bonzini <bonzini@gnu.org> wrote:
> The sync_compare_and_swap_cc optab is present to support those
> architectures where the CAS instruction touches the flag.  In this case
> better code generation is possible.  Note that combine will not help in
> this case because the CAS instruction has 2 sets (three with the CC set).
>
> However, this is not needed; the CAS expander could look for a CC set in
> the expansion of sync_compare_and_swap, and "somehow" use it to
> synthesize a branch instruction.
>
> The way to do so was anticipated in the cover letter for patch 1, in
> which I mentioned a cbranchcc4 pattern.  This patch adds a cmpcc pattern
> instead, but the idea is the same.  The advantage of doing so is that
> the CAS expander can just pass the CC register down to the
> emit_store_flag and emit_cmp_and_jump_insns machinery---the CAS
> expanders were redoing the effort of emit_store_flag, basically:
>
>  /* If the target has a sane STORE_FLAG_VALUE, then go ahead and use a
>     setcc instruction from the beginning.  We don't work too hard here,
>     but it's nice to not be stupid about initial code gen either.  */
>
> As a result, for example, -O0 code improves noticeably for s390 (not
> that this matters much, as at -O1 and above if conversion does the same
> job).
>
> Note that for simplicity I decided to have only one cmpcc pattern
> instead of one per MODE_CC mode (this required special casing of cmpcc
> but only in a couple of places).  The machine description code is
> supposed to know what it's doing, and it has a promise from the machine
> independent code that the result will only be used for EQ and NE
> comparisons.  For this reason, in patch 1 I actually had replaced a test
> with an assertion in the s390 backend.
>
> This patch was bootstrapped/regtested i686-pc-linux-gnu.  Furthermore, I
> tried compiling the affected testcases on i686-pc-linux-gnu, s390-linux
> and sparc-linux targets, both 32- and 64-bit.  There was no change in
> assembly code for SPARC (as expected, since it does not have
> sync_compare_and_swap_cc), minor register allocation changes on i686,
> and minor register allocation changes at -O1 and above on s390 (at -O0
> the code improved quite noticeably).
>
> This will be resubmitted formally for 4.5, but reviews are welcome now too.
>
> Paolo
>
> 2009-03-11  Paolo Bonzini  <bonzini@gnu.org>
>
>        * config/i386/i386.md (cmpcc): New.
>        * config/i386/sync.md (sync_compare_and_swap*): Set FLAGS_REG.
>        (sync_compare_and_swap_cc*): Delete.
>

This patch triggered:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45292

I don't know this bug was latent before.


-- 
H.J.



More information about the Gcc-patches mailing list