[RFA:] Don't strip unary ops when matching constraints. (PR target/23424)

Hans-Peter Nilsson hans-peter.nilsson@axis.com
Sun Oct 16 22:36:00 GMT 2005


I don't understand why a predicate matching an unary operator
would specify that the operand should (always) be reloaded and
the operator should be stripped before matching the constraint.
Perhaps an artefact of earlier undocumented workings.  Now it
just seems buggy.  It's not documented, and in contrast binary
operators aren't stripped (used by e.g. the ppc port).  It
causes for example (sign_extend:SI (mem:QI ...)) to be passed
as (mem:QI ...) to the constraint-test so it never matches.

Looking closer, it seems only cris-* and sh-* are affected
(having predicates that accept unary operators and using those
predicates with non-empty constraints).  I could however have
misread about others.  Regtested crosses to cris-*, sh-elf and
mips-elf, mmix-knuth-mmixware, native on
x86_64-unknown-linux-gnu, i686-pc-linux-gnu,
powerpc-unknown-linux-gnu.

Ok to commit?
:ADDPATCH RTL middle-end:

	PR target/23424
	* recog.c (constrain_operands): Don't strip unary operators.
	* reload.c (find_reloads): Ditto.

Index: recog.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/recog.c,v
retrieving revision 1.226
diff -p -u -r1.226 recog.c
--- recog.c	10 Aug 2005 09:02:48 -0000	1.226
+++ recog.c	12 Oct 2005 15:07:41 -0000
@@ -2314,11 +2314,6 @@ constrain_operands (int strict)
 
 	  earlyclobber[opno] = 0;
 
-	  /* A unary operator may be accepted by the predicate, but it
-	     is irrelevant for matching constraints.  */
-	  if (UNARY_P (op))
-	    op = XEXP (op, 0);
-
 	  if (GET_CODE (op) == SUBREG)
 	    {
 	      if (REG_P (SUBREG_REG (op))
@@ -2389,13 +2384,6 @@ constrain_operands (int strict)
 		      rtx op1 = recog_data.operand[match];
 		      rtx op2 = recog_data.operand[opno];
 
-		      /* A unary operator may be accepted by the predicate,
-			 but it is irrelevant for matching constraints.  */
-		      if (UNARY_P (op1))
-			op1 = XEXP (op1, 0);
-		      if (UNARY_P (op2))
-			op2 = XEXP (op2, 0);
-
 		      val = operands_match_p (op1, op2);
 		    }
 
Index: reload.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/reload.c,v
retrieving revision 1.275
diff -p -u -r1.275 reload.c
--- reload.c	5 Aug 2005 16:06:35 -0000	1.275
+++ reload.c	12 Oct 2005 15:07:45 -0000
@@ -2937,12 +2937,6 @@ find_reloads (rtx insn, int replace, int
 	  int constmemok = 0;
 	  int earlyclobber = 0;
 
-	  /* If the predicate accepts a unary operator, it means that
-	     we need to reload the operand, but do not do this for
-	     match_operator and friends.  */
-	  if (UNARY_P (operand) && *p != 0)
-	    operand = XEXP (operand, 0);
-
 	  /* If the operand is a SUBREG, extract
 	     the REG or MEM (or maybe even a constant) within.
 	     (Constants can occur as a result of reg_equiv_constant.)  */

brgds, H-P



More information about the Gcc-patches mailing list