[PATCH ARM/Thumb] PR 14812 fix corner cases with negate-and-compare

Richard Earnshaw rearnsha@gcc.gnu.org
Sun Apr 3 14:54:00 GMT 2005


This patch fixes a niggly corner case where negate-and-compare
operations can't be done by using the cmn instruction.  The result is
that it is unsafe in general to optimize

	neg	r0, r1
	cmp	r2, r0

into

	cmn	r2, r1

unless the following comparison is for equality.

As part of fixing this bug I've also reworked a couple of the patterns
that relied on this model so that they now have proper canonical form. 
This means that they match in practice (the non-canonical form is
probably why this bug hasn't come up much before).  Note that for the
case of 'cmn  r0, r1, <shifter-op>'  the order of the operands is
swapped from the RTL.  I've cheated slightly here by not generating a
'Swapped' CC mode, but this is safe because swapping the order of
operands when the test is for equality is a nop.

I've also fixed one other white-space warning that a recent gen* change
must have uncovered.

Tested on an arm-elf cross for both ARM and Thumb.

R.

2005-04-03  Richard Earnshaw  <richard.earnshaw@arm.com>

	PR target/14812
	* arm.md (addsi3_compare0_for_combiner): Delete.
	(addsi3_compare0_scratch_for_combiner): Delete.
	(cmpsi_neg_shiftsi): Delete.
	(compare_negsi_si): New pattern.
	(cmpsi_negshiftsi_si): New pattern.
	(negated_cbranchsi4): Restrict to equality_operator.
	
	* arm.md (movhi_insn_arch4): delete trailing white space from assembler
	template.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: cmn-audit.patch
Type: text/x-patch
Size: 4109 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20050403/f3dd163e/attachment.bin>


More information about the Gcc-patches mailing list