diff mbox

RX: Fix LT and GE comparisons

Message ID 4D4EDE2E.8000903@redhat.com
State New
Headers show

Commit Message

Richard Henderson Feb. 6, 2011, 5:45 p.m. UTC
On 02/04/2011 10:19 AM, Richard Henderson wrote:
> I suppose one could verify that Y is const0_rtx in rx_select_cc_mode before
> selecting CC_FLAG_S for these codes.  I thought it was already always zero
> though, thus the trivial implementation of that routine.
> 
> Can you point me to one of the tests that are fixed by this change?

Irritatingly, I didn't copy the dejagnu magic for rx-sim onto this machine
before I ran tests last night, but see if this patch doesn't solve the 
problem you were trying to address.


r~

Comments

Nick Clifton Feb. 7, 2011, 5:05 p.m. UTC | #1
Hi Richard,


> Irritatingly, I didn't copy the dejagnu magic for rx-sim onto this machine
> before I ran tests last night, but see if this patch doesn't solve the
> problem you were trying to address.

Hmm, it does fix the same testcases that my patch fixed.  But it also 
appears to introduce a new failure:

   gcc/testsuite/gcc.dg/tree-ssa/pr42327.c: In function 'foo':
   gcc/testsuite/gcc.dg/tree-ssa/pr42327.c:4:6: internal compiler error:
    Segmentation fault

However this appears to be a memory corruption in the omega code, which 
is unlikely to be connected with RX comparison instructions.  So I think 
that maybe it is just a case that a new bug has been introduced into the 
gcc sources between the time that I ran my pre-patch tests and today. 
I'll try reverting your patch and my patch and then running the 
testsuite again to make absolutely sure.

Cheers
   Nick
Nick Clifton Feb. 8, 2011, 12:32 p.m. UTC | #2
Hi Richard,

> Irritatingly, I didn't copy the dejagnu magic for rx-sim onto this machine
> before I ran tests last night, but see if this patch doesn't solve the
> problem you were trying to address.

I have now rerun the gcc testsuite without your patch applied or mine, 
and unfortunately gcc.dg/tree-ssa/pr42327.c passes.  So there must be 
something in your patch that is triggering this failure.  Any ideas ?

Cheers
   Nick
Richard Henderson Feb. 9, 2011, 5:37 p.m. UTC | #3
On 02/08/2011 04:32 AM, Nick Clifton wrote:
> I have now rerun the gcc testsuite without your patch applied or
> mine, and unfortunately gcc.dg/tree-ssa/pr42327.c passes.  So there
> must be something in your patch that is triggering this failure.  Any
> ideas ?

None.  I can't reproduce this with r169926 with and without my patch.


r~
Nick Clifton Feb. 10, 2011, 2:51 p.m. UTC | #4
Hi Richard,

> None.  I can't reproduce this with r169926 with and without my patch.

Hmm, must be something in my local setup then.  Could you check your 
patch in please ?

Cheers
   Nick
diff mbox

Patch

diff --git a/gcc/config/rx/predicates.md b/gcc/config/rx/predicates.md
index 82cac42..77b3353 100644
--- a/gcc/config/rx/predicates.md
+++ b/gcc/config/rx/predicates.md
@@ -284,7 +284,7 @@ 
 )
 
 (define_predicate "rx_zs_comparison_operator"
-  (match_code "eq,ne")
+  (match_code "eq,ne,lt,ge")
 )
 
 ;; GT and LE omitted due to operand swap required.
diff --git a/gcc/config/rx/rx.c b/gcc/config/rx/rx.c
index 839523f..e01f453 100644
--- a/gcc/config/rx/rx.c
+++ b/gcc/config/rx/rx.c
@@ -447,13 +447,14 @@  rx_print_operand (FILE * file, rtx op, int letter)
 	  }
 	else
 	  {
+	    unsigned int flags = flags_from_mode (mode);
 	    switch (code)
 	      {
 	      case LT:
-		ret = "lt";
+		ret = (flags & CC_FLAG_O ? "lt" : "n");
 		break;
 	      case GE:
-		ret = "ge";
+		ret = (flags & CC_FLAG_O ? "ge" : "pz");
 		break;
 	      case GT:
 		ret = "gt";
@@ -482,8 +483,7 @@  rx_print_operand (FILE * file, rtx op, int letter)
 	      default:
 		gcc_unreachable ();
 	      }
-	    gcc_checking_assert ((flags_from_code (code)
-				  & ~flags_from_mode (mode)) == 0);
+	    gcc_checking_assert ((flags_from_code (code) & ~flags) == 0);
 	  }
 	fputs (ret, file);
 	break;
@@ -2625,7 +2625,7 @@  flags_from_code (enum rtx_code code)
     {
     case LT:
     case GE:
-      return CC_FLAG_S | CC_FLAG_O;
+      return CC_FLAG_S;
     case GT:
     case LE:
       return CC_FLAG_S | CC_FLAG_O | CC_FLAG_Z;
@@ -2666,11 +2666,14 @@  rx_cc_modes_compatible (enum machine_mode m1, enum machine_mode m2)
 /* Return the minimal CC mode needed to implement (CMP_CODE X Y).  */
 
 enum machine_mode
-rx_select_cc_mode (enum rtx_code cmp_code, rtx x, rtx y ATTRIBUTE_UNUSED)
+rx_select_cc_mode (enum rtx_code cmp_code, rtx x, rtx y)
 {
   if (GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT)
     return CC_Fmode;
 
+  if (y != const0_rtx)
+    return CCmode;
+
   return mode_from_flags (flags_from_code (cmp_code));
 }