This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Get comparison mode from old and new operands


simplify_relational_operation would abort() on mn10300-elf because,
under certain conditions, it would get a mode == VOIDmode when at
least one of the operands was not VOIDmode.  That was because the call
of simplify_gen_relational() in simplify_replace_rtx() was trying to
obtain the modes from the original operands of the relational
operation, that happened to be (cc0) and (const_int 0), but the (cc0)
was being replaced with an label_ref:SI.

At first, I had the impression the function call invoked undefined
behavior, in case simplify_replace_rtx() modified the operands
in-place, but seems that it never does that, so it would be safe to
evaluate XEXP (x, [01]) multiple times when computing the arguments to
the call.  But when I noticed it never does that, I had already moved
the computation of the arguments out of the function call expression.
In any case, this re-arranging was necessary to be able to use both
the original and the replacement operands to try to find out the mode
of the operation.

This gets mn10300-elf to build all of newlib, libgloss and libiberty
on alpha.  Still stumbling into problems while building libstdc++-v3,
because the assembler doesn't support certain differences between
symbols that are generated when compiling libsupc++ with -prefer-pic.
I'll address this problem in a separate message.

Ok to install?

Index: gcc/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* simplify-rtx.c (simplify_replace_rtx): Try to obtain mode
	from old and new operands in `<', `3' and `b'.

Index: gcc/simplify-rtx.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/simplify-rtx.c,v
retrieving revision 1.47
diff -u -p -r1.47 simplify-rtx.c
--- gcc/simplify-rtx.c 2001/05/01 12:11:34 1.47
+++ gcc/simplify-rtx.c 2001/05/03 18:48:44
@@ -242,21 +242,38 @@ simplify_replace_rtx (x, old, new)
 			     simplify_replace_rtx (XEXP (x, 0), old, new),
 			     simplify_replace_rtx (XEXP (x, 1), old, new));
     case '<':
-      return
-	simplify_gen_relational (code, mode,
-				 (GET_MODE (XEXP (x, 0)) != VOIDmode
-				  ? GET_MODE (XEXP (x, 0))
-				  : GET_MODE (XEXP (x, 1))),
-				 simplify_replace_rtx (XEXP (x, 0), old, new),
-				 simplify_replace_rtx (XEXP (x, 1), old, new));
+      {
+	enum machine_mode op_mode = (GET_MODE (XEXP (x, 0)) != VOIDmode
+				     ? GET_MODE (XEXP (x, 0))
+				     : GET_MODE (XEXP (x, 1)));
+	rtx op0 = simplify_replace_rtx (XEXP (x, 0), old, new);
+	rtx op1 = simplify_replace_rtx (XEXP (x, 1), old, new);
 
+	return
+	  simplify_gen_relational (code, mode,
+				   (op_mode != VOIDmode
+				    ? op_mode
+				    : GET_MODE (op0) != VOIDmode
+				    ? GET_MODE (op0)
+				    : GET_MODE (op1)),
+				   op0, op1);
+      }
+
     case '3':
     case 'b':
-      return
-	simplify_gen_ternary (code, mode, GET_MODE (XEXP (x, 0)),
-			      simplify_replace_rtx (XEXP (x, 0), old, new),
-			      simplify_replace_rtx (XEXP (x, 1), old, new),
-			      simplify_replace_rtx (XEXP (x, 2), old, new));
+      {
+	enum machine_mode op_mode = GET_MODE (XEXP (x, 0));
+	rtx op0 = simplify_replace_rtx (XEXP (x, 0), old, new);
+
+	return
+	  simplify_gen_ternary (code, mode, 
+				(op_mode != VOIDmode
+				 ? op_mode
+				 : GET_MODE (op0)),
+				op0,
+				simplify_replace_rtx (XEXP (x, 1), old, new),
+				simplify_replace_rtx (XEXP (x, 2), old, new));
+      }
 
     case 'x':
       /* The only case we try to handle is a lowpart SUBREG of a single-word

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist    *Please* write to mailing lists, not to me

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]