compare-elim.c (try_eliminate_compare): Also handle operands with implicit extensions.
authorUros Bizjak <uros@gcc.gnu.org>
Wed, 25 Apr 2012 06:05:26 +0000 (08:05 +0200)
committerUros Bizjak <uros@gcc.gnu.org>
Wed, 25 Apr 2012 06:05:26 +0000 (08:05 +0200)
* compare-elim.c (try_eliminate_compare): Also handle operands with
implicit extensions.

From-SVN: r186805

gcc/ChangeLog
gcc/compare-elim.c

index 4daecb4776ece5c369352534919f26c80c831830..c7d8eac13ce047963a99d05c2b505cbdd20f2fdc 100644 (file)
@@ -1,3 +1,8 @@
+2012-04-25  Uros Bizjak  <ubizjak@gmail.com>
+
+       * compare-elim.c (try_eliminate_compare): Also handle operands with
+       implicit extensions.
+
 2012-04-25  Alan Modra  <amodra@gmail.com>
 
        * config/rs6000/rs6000 (SAVE_INLINE_VRS, REST_INLINE_VRS,
 2012-04-24  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/53084
-       * varasm.c (compute_reloc_for_constant): Handle ADDR_EXPR
-       of MEM_REF.
+       * varasm.c (compute_reloc_for_constant): Handle ADDR_EXPR of MEM_REF.
        (output_addressed_constants): Likewise.
 
        PR middle-end/52999
index 5157e766e8ae620df1878d60ebc7e15fac72e93e..f11a7245caa9909811bc1c6f3808b9191f13da26 100644 (file)
@@ -563,10 +563,26 @@ try_eliminate_compare (struct comparison *cmp)
      Validate that PREV_CLOBBER itself does in fact refer to IN_A.  Do
      recall that we've already validated the shape of PREV_CLOBBER.  */
   x = XVECEXP (PATTERN (insn), 0, 0);
-  if (!rtx_equal_p (SET_DEST (x), in_a))
+  if (rtx_equal_p (SET_DEST (x), in_a))
+    cmp_src = SET_SRC (x);
+
+  /* Also check operations with implicit extensions, e.g.:
+     [(set (reg:DI)
+          (zero_extend:DI (plus:SI (reg:SI)(reg:SI))))
+      (set (reg:CCZ flags)
+          (compare:CCZ
+            (plus:SI (reg:SI)(reg:SI))
+            (const_int 0)))]                           */
+  else if (REG_P (SET_DEST (x))
+          && REG_P (in_a)
+          && REGNO (SET_DEST (x)) == REGNO (in_a)
+          && (GET_CODE (SET_SRC (x)) == ZERO_EXTEND
+              || GET_CODE (SET_SRC (x)) == SIGN_EXTEND)
+          && GET_MODE (XEXP (SET_SRC (x), 0)) == GET_MODE (in_a))
+    cmp_src = XEXP (SET_SRC (x), 0);
+  else
     return false;
-  cmp_src = SET_SRC (x);
-  
+
   /* Determine if we ought to use a different CC_MODE here.  */
   flags = maybe_select_cc_mode (cmp, cmp_src, cmp->in_b);
   if (flags == NULL)