[cond-optab] simplify logic to emit compares

Paolo Bonzini bonzini@gnu.org
Wed Mar 11 15:31:00 GMT 2009


Most current ports, when emitting a cmp instruction, actually store the
operands because the right MODE_CC mode for the comparison is unknown
until the branch condition comes.  To simplify this, the cbranch optab
was introduced.  The optab would be filled with define_expand constructs
which would synthesize the appropriate comparison and branch.

However, one of the problems with the cbranch optab is that in some
cases an instruction is already known to fill the CC register.  This
patch prepares the backends to use the same variables in this case as
for the normal compare/branch sequence.  So, instead of filling the
xxx_compare_emitted variable with the CC register in the appropriate
mode, the ports place it in xxx_compare_op0 and put const0_rtx in
xxx_compare_op1.  When the compare emitters find a CC register in
xxx_compare_op0, they just use it instead of emitting a comparison.

At the end of this series, the backends won't have to special case this
anymore, and this will be represented with a cmpcc or cbranchcc4
pattern, where the comparison operands are again the CC register
(derived from the previous insn) and const0_rtx.

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, with no change in assembly
code.

This will be resubmitted formally for 4.5, but reviews are welcome now too.

Paolo
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 01.patch
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20090311/74246c31/attachment.ksh>


More information about the Gcc-patches mailing list