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]

i386 FP conditional move signed integer comparison patch


This patch adds support for using signed integer comparisons with
FP conditional moves.  The support is implemented at the RTL level
which allows the compiler an opportunity to optimize the resulting
code.

ChangeLog:

Sun Jun 14 18:46:26 EDT 1998  John Wehle  (john@feith.com)

	* i386.md (movsfcc, movdfcc, movxfcc): Use emit_store_flag
	to support LT, LE, GE, and GT signed integer comparisons.
	(movsfcc+1, movsfcc+2, movdfcc+1, movdfcc+2,
	movxfcc+1, movxfcc+2): Pattern doesn't match if the comparison
	is LT, LE, GE, or GT.

Enjoy!

-- John Wehle
------------------8<------------------------8<------------------------
*** gcc/config/i386/i386.md.ORIGINAL	Fri Jun 12 22:26:02 1998
--- gcc/config/i386/i386.md	Sun Jun 14 20:13:06 1998
***************
*** 7368,7378 ****
    "TARGET_CMOVE"
    "
  {
    if (GET_MODE_CLASS (GET_MODE (i386_compare_op0)) != MODE_INT)
      FAIL;
  
!   /* The floating point conditional move instructions don't support
!      conditions resulting from a signed comparison. */
  
    switch (GET_CODE (operands[1]))
      {
--- 7368,7380 ----
    "TARGET_CMOVE"
    "
  {
+   rtx temp;
+ 
    if (GET_MODE_CLASS (GET_MODE (i386_compare_op0)) != MODE_INT)
      FAIL;
  
!   /* The floating point conditional move instructions don't directly
!      support conditions resulting from a signed integer comparison. */
  
    switch (GET_CODE (operands[1]))
      {
***************
*** 7380,7396 ****
      case LE:
      case GE:
      case GT:
!       FAIL;
!     /* NOTREACHED */
!       break;
  
!     default:
        break;
-     }
  
!   operands[1] = gen_rtx_fmt_ee (GET_CODE (operands[1]),
  			GET_MODE (i386_compare_op0),
  			i386_compare_op0, i386_compare_op1);
  }")
  
  (define_insn ""
--- 7382,7403 ----
      case LE:
      case GE:
      case GT:
!       temp = emit_store_flag (gen_reg_rtx (QImode),
! 		GET_CODE (operands[1]), i386_compare_op0, i386_compare_op1,
! 		VOIDmode, 0, 0);
  
!       if ( !temp )
!         FAIL;
! 
!       operands[1] = gen_rtx_fmt_ee (NE, QImode, temp, const0_rtx);
        break;
  
!     default:
!       operands[1] = gen_rtx_fmt_ee (GET_CODE (operands[1]),
  			GET_MODE (i386_compare_op0),
  			i386_compare_op0, i386_compare_op1);
+       break;
+     }
  }")
  
  (define_insn ""
***************
*** 7400,7406 ****
  		(match_operand:QI 3 "general_operand" "qmn,qn,qmn,qn,qmn,qn")])
  	      (match_operand:SF 4 "register_operand" "f,f,0,0,f,f")
  	      (match_operand:SF 5 "register_operand" "0,0,f,f,f,f")))]
!   "TARGET_CMOVE"
    "#")
  
  (define_insn ""
--- 7407,7415 ----
  		(match_operand:QI 3 "general_operand" "qmn,qn,qmn,qn,qmn,qn")])
  	      (match_operand:SF 4 "register_operand" "f,f,0,0,f,f")
  	      (match_operand:SF 5 "register_operand" "0,0,f,f,f,f")))]
!   "TARGET_CMOVE
!     && GET_CODE (operands[1]) != LT && GET_CODE (operands[1]) != LE
!     && GET_CODE (operands[1]) != GE && GET_CODE (operands[1]) != GT"
    "#")
  
  (define_insn ""
***************
*** 7410,7416 ****
  		 (match_operand 3 "general_operand" "rmi,ri,rmi,ri,rmi,ri")])
  	      (match_operand:SF 4 "register_operand" "f,f,0,0,f,f")
  	      (match_operand:SF 5 "register_operand" "0,0,f,f,f,f")))]
!   "TARGET_CMOVE && GET_MODE_CLASS (GET_MODE (operands[2])) == MODE_INT"
    "#")
  
  (define_split
--- 7419,7427 ----
  		 (match_operand 3 "general_operand" "rmi,ri,rmi,ri,rmi,ri")])
  	      (match_operand:SF 4 "register_operand" "f,f,0,0,f,f")
  	      (match_operand:SF 5 "register_operand" "0,0,f,f,f,f")))]
!   "TARGET_CMOVE && GET_MODE_CLASS (GET_MODE (operands[2])) == MODE_INT
!     && GET_CODE (operands[1]) != LT && GET_CODE (operands[1]) != LE
!     && GET_CODE (operands[1]) != GE && GET_CODE (operands[1]) != GT"
    "#")
  
  (define_split
***************
*** 7459,7469 ****
    "TARGET_CMOVE"
    "
  {
    if (GET_MODE_CLASS (GET_MODE (i386_compare_op0)) != MODE_INT)
      FAIL;
  
!   /* The floating point conditional move instructions don't support
!      conditions resulting from a signed comparison. */
  
    switch (GET_CODE (operands[1]))
      {
--- 7470,7482 ----
    "TARGET_CMOVE"
    "
  {
+   rtx temp;
+ 
    if (GET_MODE_CLASS (GET_MODE (i386_compare_op0)) != MODE_INT)
      FAIL;
  
!   /* The floating point conditional move instructions don't directly
!      support conditions resulting from a signed integer comparison. */
  
    switch (GET_CODE (operands[1]))
      {
***************
*** 7471,7487 ****
      case LE:
      case GE:
      case GT:
!       FAIL;
!     /* NOTREACHED */
!       break;
  
!     default:
        break;
-     }
  
!   operands[1] = gen_rtx_fmt_ee (GET_CODE (operands[1]),
  			GET_MODE (i386_compare_op0),
  			i386_compare_op0, i386_compare_op1);
  }")
  
  (define_insn ""
--- 7484,7505 ----
      case LE:
      case GE:
      case GT:
!       temp = emit_store_flag (gen_reg_rtx (QImode),
! 		GET_CODE (operands[1]), i386_compare_op0, i386_compare_op1,
! 		VOIDmode, 0, 0);
  
!       if ( !temp )
!         FAIL;
! 
!       operands[1] = gen_rtx_fmt_ee (NE, QImode, temp, const0_rtx);
        break;
  
!     default:
!       operands[1] = gen_rtx_fmt_ee (GET_CODE (operands[1]),
  			GET_MODE (i386_compare_op0),
  			i386_compare_op0, i386_compare_op1);
+       break;
+     }
  }")
  
  (define_insn ""
***************
*** 7491,7497 ****
  		(match_operand:QI 3 "general_operand" "qmn,qn,qmn,qn,qmn,qn")])
  	      (match_operand:DF 4 "register_operand" "f,f,0,0,f,f")
  	      (match_operand:DF 5 "register_operand" "0,0,f,f,f,f")))]
!   "TARGET_CMOVE"
    "#")
  
  (define_insn ""
--- 7509,7517 ----
  		(match_operand:QI 3 "general_operand" "qmn,qn,qmn,qn,qmn,qn")])
  	      (match_operand:DF 4 "register_operand" "f,f,0,0,f,f")
  	      (match_operand:DF 5 "register_operand" "0,0,f,f,f,f")))]
!   "TARGET_CMOVE
!     && GET_CODE (operands[1]) != LT && GET_CODE (operands[1]) != LE
!     && GET_CODE (operands[1]) != GE && GET_CODE (operands[1]) != GT"
    "#")
  
  (define_insn ""
***************
*** 7501,7507 ****
  		(match_operand 3 "general_operand" "rmi,ri,rmi,ri,rmi,ri")])
  	      (match_operand:DF 4 "register_operand" "f,f,0,0,f,f")
  	      (match_operand:DF 5 "register_operand" "0,0,f,f,f,f")))]
!   "TARGET_CMOVE && GET_MODE_CLASS (GET_MODE (operands[2])) == MODE_INT"
    "#")
  
  (define_split
--- 7521,7529 ----
  		(match_operand 3 "general_operand" "rmi,ri,rmi,ri,rmi,ri")])
  	      (match_operand:DF 4 "register_operand" "f,f,0,0,f,f")
  	      (match_operand:DF 5 "register_operand" "0,0,f,f,f,f")))]
!   "TARGET_CMOVE && GET_MODE_CLASS (GET_MODE (operands[2])) == MODE_INT
!     && GET_CODE (operands[1]) != LT && GET_CODE (operands[1]) != LE
!     && GET_CODE (operands[1]) != GE && GET_CODE (operands[1]) != GT"
    "#")
  
  (define_split
***************
*** 7550,7560 ****
    "TARGET_CMOVE"
    "
  {
    if (GET_MODE_CLASS (GET_MODE (i386_compare_op0)) != MODE_INT)
      FAIL;
  
!   /* The floating point conditional move instructions don't support
!      conditions resulting from a signed comparison. */
  
    switch (GET_CODE (operands[1]))
      {
--- 7572,7584 ----
    "TARGET_CMOVE"
    "
  {
+   rtx temp;
+ 
    if (GET_MODE_CLASS (GET_MODE (i386_compare_op0)) != MODE_INT)
      FAIL;
  
!   /* The floating point conditional move instructions don't directly
!      support conditions resulting from a signed integer comparison. */
  
    switch (GET_CODE (operands[1]))
      {
***************
*** 7562,7578 ****
      case LE:
      case GE:
      case GT:
!       FAIL;
!     /* NOTREACHED */
!       break;
  
!     default:
        break;
-     }
  
!   operands[1] = gen_rtx_fmt_ee (GET_CODE (operands[1]),
  			GET_MODE (i386_compare_op0),
  			i386_compare_op0, i386_compare_op1);
  }")
  
  (define_insn ""
--- 7586,7607 ----
      case LE:
      case GE:
      case GT:
!       temp = emit_store_flag (gen_reg_rtx (QImode),
! 		GET_CODE (operands[1]), i386_compare_op0, i386_compare_op1,
! 		VOIDmode, 0, 0);
  
!       if ( !temp )
!         FAIL;
! 
!       operands[1] = gen_rtx_fmt_ee (NE, QImode, temp, const0_rtx);
        break;
  
!     default:
!       operands[1] = gen_rtx_fmt_ee (GET_CODE (operands[1]),
  			GET_MODE (i386_compare_op0),
  			i386_compare_op0, i386_compare_op1);
+       break;
+     }
  }")
  
  (define_insn ""
***************
*** 7582,7588 ****
  		(match_operand:QI 3 "general_operand" "qmn,qn,qmn,qn,qmn,qn")])
  	      (match_operand:XF 4 "register_operand" "f,f,0,0,f,f")
  	      (match_operand:XF 5 "register_operand" "0,0,f,f,f,f")))]
!   "TARGET_CMOVE"
    "#")
  
  (define_insn ""
--- 7611,7619 ----
  		(match_operand:QI 3 "general_operand" "qmn,qn,qmn,qn,qmn,qn")])
  	      (match_operand:XF 4 "register_operand" "f,f,0,0,f,f")
  	      (match_operand:XF 5 "register_operand" "0,0,f,f,f,f")))]
!   "TARGET_CMOVE
!     && GET_CODE (operands[1]) != LT && GET_CODE (operands[1]) != LE
!     && GET_CODE (operands[1]) != GE && GET_CODE (operands[1]) != GT"
    "#")
  
  (define_insn ""
***************
*** 7592,7598 ****
  		(match_operand 3 "general_operand" "rmi,ri,rmi,ri,rmi,ri")])
  	      (match_operand:XF 4 "register_operand" "f,f,0,0,f,f")
  	      (match_operand:XF 5 "register_operand" "0,0,f,f,f,f")))]
!   "TARGET_CMOVE && GET_MODE_CLASS (GET_MODE (operands[2])) == MODE_INT"
    "#")
  
  (define_split
--- 7623,7631 ----
  		(match_operand 3 "general_operand" "rmi,ri,rmi,ri,rmi,ri")])
  	      (match_operand:XF 4 "register_operand" "f,f,0,0,f,f")
  	      (match_operand:XF 5 "register_operand" "0,0,f,f,f,f")))]
!   "TARGET_CMOVE && GET_MODE_CLASS (GET_MODE (operands[2])) == MODE_INT
!     && GET_CODE (operands[1]) != LT && GET_CODE (operands[1]) != LE
!     && GET_CODE (operands[1]) != GE && GET_CODE (operands[1]) != GT"
    "#")
  
  (define_split
-------------------------------------------------------------------------
|   Feith Systems  |   Voice: 1-215-646-8000  |  Email: john@feith.com  |
|    John Wehle    |     Fax: 1-215-540-5495  |                         |
-------------------------------------------------------------------------



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