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]
Other format: [Raw text]

[PATCH] PR middle-end/19697: Fix PA's adddi3 and iordi3 patterns


This is the main part of my two fixes to PR middle-end/19697 (though
it looks like RTH is now handling improving optimization in
expand_copysign).  This part address the true problem, that the condition
checking for the andi3 and iordi3 patterns is incorrect.  Currently, for
TARGET_64BIT, these expanders succeed if either operands[1] or operands[2]
is a register.  Unfortunately, the corresponding anonymous patterns for
TARGET_64BIT only permit the register to be operand[1], hence the
unrecognizable insn in the PR.

There are two possible backend solutions.  Either (i) strengthen the
conditions on the expander to accept only the form that's recognized,
or (ii) allow the reversed form either by swapping the operands in the
expander, or by swapping the operands in the define_insn.  The patch
below implements (i), as I believe that if the condition/predicates
are correctly represented then expand/recog will do the necessary
swapping for us.

The following patch has been tested on hppa64-hp-hpux11.00 with a full
"make bootstrap", all default languages, hosted on hppa2.0w-hp-hpux11.00
with CC="/usr/bin/cc +DD64", and regression tested with a top-level "make
-k check" with no new failures.  On this platform, the patch below fixes
the failure of gcc.c-torture/execute/ieee/mzero6.c.

Ok for mainline?  Or would a swapping solution be preferred?



2005-01-30  Roger Sayle  <roger@eyesopen.com>

	PR middle-end/19697
	* config/pa/pa.md (anddi3, iordi3): On HPPA64, disallow an integer
	constant as the second operand and a register as the third.


Index: pa.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/pa/pa.md,v
retrieving revision 1.157
diff -c -3 -p -r1.157 pa.md
*** pa.md	15 Jan 2005 22:57:15 -0000	1.157
--- pa.md	30 Jan 2005 19:39:02 -0000
***************
*** 5441,5465 ****

  (define_expand "anddi3"
    [(set (match_operand:DI 0 "register_operand" "")
! 	(and:DI (match_operand:DI 1 "and_operand" "")
  		(match_operand:DI 2 "and_operand" "")))]
    ""
    "
  {
!   if (TARGET_64BIT)
!     {
!       /* One operand must be a register operand.  */
!       if (!register_operand (operands[1], DImode)
! 	  && !register_operand (operands[2], DImode))
! 	FAIL;
!     }
!   else
!     {
!       /* Both operands must be register operands.  */
!       if (!register_operand (operands[1], DImode)
! 	  || !register_operand (operands[2], DImode))
! 	FAIL;
!     }
  }")

  (define_insn ""
--- 5441,5454 ----

  (define_expand "anddi3"
    [(set (match_operand:DI 0 "register_operand" "")
! 	(and:DI (match_operand:DI 1 "register_operand" "")
  		(match_operand:DI 2 "and_operand" "")))]
    ""
    "
  {
!   /* Both operands must be register operands.  */
!   if (!TARGET_64BIT && !register_operand (operands[2], DImode))
!     FAIL;
  }")

  (define_insn ""
***************
*** 5520,5544 ****

  (define_expand "iordi3"
    [(set (match_operand:DI 0 "register_operand" "")
! 	(ior:DI (match_operand:DI 1 "ior_operand" "")
  		(match_operand:DI 2 "ior_operand" "")))]
    ""
    "
  {
!   if (TARGET_64BIT)
!     {
!       /* One operand must be a register operand.  */
!       if (!register_operand (operands[1], DImode)
! 	  && !register_operand (operands[2], DImode))
! 	FAIL;
!     }
!   else
!     {
!       /* Both operands must be register operands.  */
!       if (!register_operand (operands[1], DImode)
! 	  || !register_operand (operands[2], DImode))
! 	FAIL;
!     }
  }")

  (define_insn ""
--- 5509,5522 ----

  (define_expand "iordi3"
    [(set (match_operand:DI 0 "register_operand" "")
! 	(ior:DI (match_operand:DI 1 "register_operand" "")
  		(match_operand:DI 2 "ior_operand" "")))]
    ""
    "
  {
!   /* Both operands must be register operands.  */
!   if (!TARGET_64BIT && !register_operand (operands[2], DImode))
!     FAIL;
  }")

  (define_insn ""


Roger
--
Roger Sayle,                         E-mail: roger@eyesopen.com
OpenEye Scientific Software,         WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road,     Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507.         Fax: (+1) 505-473-0833


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