diff mbox

[rtl-optimization] : Fix post-reload compare elimination pre-pass

Message ID CAFULd4aofE3Gjv3O4S0X=QP5J31hjpitFTHmkLAQB7031LZVsA@mail.gmail.com
State New
Headers show

Commit Message

Uros Bizjak Feb. 11, 2012, 8:16 a.m. UTC
On Sat, Feb 11, 2012 at 1:26 AM, Richard Henderson <rth@redhat.com> wrote:
> On 02/09/2012 03:47 PM, Uros Bizjak wrote:
>> 2012-02-10  Uros Bizjak  <ubizjak@gmail.com>
>>
>>       * compare-elim.c (find_comparisons_in_bb): Eliminate only compares
>>       having mode compatible with the mode of previous compare.  Substitute
>>       compare mode of previous compare with the mode, compatible
>>       with eliminated and previous compare.
>
> This patch is ok for 4.8.
>
> For 4.6 and 4.7 I would prefer that we simply not eliminate the compare.  I.e.

> For 4.6 and 4.7, there are only two extant users of this pass and neither
> of them use anything besides CCmode before compare-elim.c does its own
> manipulation of the modes later.

Attached patch is what I have committed to 4.6 and 4.7.

2012-02-11  Uros Bizjak  <ubizjak@gmail.com>

	* compare-elim.c (find_comparisons_in_bb): Eliminate only compares
	having the same mode as previous compare.

Bootstrapped and regression tested on x86_64-pc-linux-gnu {,-m32},
together with a target-patch that enables this functionality.

Uros.
diff mbox

Patch

Index: compare-elim.c
===================================================================
--- compare-elim.c	(revision 184123)
+++ compare-elim.c	(working copy)
@@ -297,8 +297,11 @@  find_comparisons_in_bb (struct dom_walk_data *data
       src = conforming_compare (insn);
       if (src)
 	{
+	  enum machine_mode src_mode = GET_MODE (src);
+
 	  /* Eliminate a compare that's redundant with the previous.  */
 	  if (last_cmp_valid
+	      && src_mode == last_cmp->orig_mode
 	      && rtx_equal_p (last_cmp->in_a, XEXP (src, 0))
 	      && rtx_equal_p (last_cmp->in_b, XEXP (src, 1)))
 	    {
@@ -311,7 +314,7 @@  find_comparisons_in_bb (struct dom_walk_data *data
 	  last_cmp->prev_clobber = last_clobber;
 	  last_cmp->in_a = XEXP (src, 0);
 	  last_cmp->in_b = XEXP (src, 1);
-	  last_cmp->orig_mode = GET_MODE (SET_DEST (single_set (insn)));
+	  last_cmp->orig_mode = src_mode;
 	  VEC_safe_push (comparison_struct_p, heap, all_compares, last_cmp);
 
 	  /* It's unusual, but be prepared for comparison patterns that