* combine.c (simplify_set): Try harder to find the best CC mode when
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 22 Mar 2011 20:04:58 +0000 (20:04 +0000)
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 22 Mar 2011 20:04:58 +0000 (20:04 +0000)
simplifying a nested COMPARE on the RHS.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@171304 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/combine.c

index efe5aa1..a6fa3dd 100644 (file)
@@ -1,3 +1,8 @@
+2011-03-22  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * combine.c (simplify_set): Try harder to find the best CC mode when
+       simplifying a nested COMPARE on the RHS.
+
 2011-03-22  Joseph Myers  <joseph@codesourcery.com>
 
        * config/alpha/gnu.h: Remove.
index fe3302a..60bd9ee 100644 (file)
@@ -6240,10 +6240,18 @@ simplify_set (rtx x)
       enum rtx_code new_code;
       rtx op0, op1, tmp;
       int other_changed = 0;
+      rtx inner_compare = NULL_RTX;
       enum machine_mode compare_mode = GET_MODE (dest);
 
       if (GET_CODE (src) == COMPARE)
-       op0 = XEXP (src, 0), op1 = XEXP (src, 1);
+       {
+         op0 = XEXP (src, 0), op1 = XEXP (src, 1);
+         if (GET_CODE (op0) == COMPARE && op1 == const0_rtx)
+           {
+             inner_compare = op0;
+             op0 = XEXP (inner_compare, 0), op1 = XEXP (inner_compare, 1);
+           }
+       }
       else
        op0 = src, op1 = CONST0_RTX (GET_MODE (src));
 
@@ -6285,6 +6293,12 @@ simplify_set (rtx x)
         need to use a different CC mode here.  */
       if (GET_MODE_CLASS (GET_MODE (op0)) == MODE_CC)
        compare_mode = GET_MODE (op0);
+      else if (inner_compare
+              && GET_MODE_CLASS (GET_MODE (inner_compare)) == MODE_CC
+              && new_code == old_code
+              && op0 == XEXP (inner_compare, 0)
+              && op1 == XEXP (inner_compare, 1))
+       compare_mode = GET_MODE (inner_compare);
       else
        compare_mode = SELECT_CC_MODE (new_code, op0, op1);