MIPS patch to simplify test for float 1.0 constant

James E Wilson wilson@specifixinc.com
Sat Aug 14 07:03:00 GMT 2004


This simplifies the code in const_float_1_operand.  There is no need to
convert the rtl to a real value to check for a constant 1.  We can
simply use CONST1_RTX.

The reason I care is because the CONST1_RTX trick works for vector float
modes, but the REAL_VALUE_ stuff won't without a bit of work.  Thus this
patch makes the code both faster and more general.

Compiling the testcase with -O -ffast-math shows that we still get recip
instructions, and hence the const_float_1_operand predicate is still
working.

This was tested with an sb1-elf build and make check from a combined
tree, with the C and C++ languages enabled.  There were no regressions.
-- 
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com

-------------- next part --------------
2004-08-13  James E Wilson  <wilson@specifixinc.com>

	* config/mips/mips.c (const_float_1_operand): Use CONST1_RTX not
	REAL_VALUE_FROM_CONST_DOUBLE and REAL_VALUES_EQUAL.

Index: mips.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/mips.c,v
retrieving revision 1.442
diff -p -r1.442 mips.c
*** mips.c	1 Aug 2004 11:36:25 -0000	1.442
--- mips.c	13 Aug 2004 22:48:19 -0000
*************** reg_or_const_float_1_operand (rtx op, en
*** 1385,1400 ****
  int
  const_float_1_operand (rtx op, enum machine_mode mode)
  {
-   REAL_VALUE_TYPE d;
- 
    if (GET_CODE (op) != CONST_DOUBLE
        || mode != GET_MODE (op)
        || (mode != DFmode && mode != SFmode))
      return 0;
  
!   REAL_VALUE_FROM_CONST_DOUBLE (d, op);
! 
!   return REAL_VALUES_EQUAL (d, dconst1);
  }
  
  /* Return true if OP is either the HI or LO register.  */
--- 1385,1396 ----
  int
  const_float_1_operand (rtx op, enum machine_mode mode)
  {
    if (GET_CODE (op) != CONST_DOUBLE
        || mode != GET_MODE (op)
        || (mode != DFmode && mode != SFmode))
      return 0;
  
!   return op == CONST1_RTX (mode);
  }
  
  /* Return true if OP is either the HI or LO register.  */
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tmp.c
Type: text/x-c
Size: 89 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20040814/452e0938/attachment.bin>


More information about the Gcc-patches mailing list