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]

Avoid LOAD_EXTEND_OP on non-integer mode


The documentation for LOAD_EXTEND_OP says:

    This macro is not called with @var{mem_mode} non-integral or with a
    width greater than or equal to @code{BITS_PER_WORD}, so you may return
    any value in this case.

However, it does appear to be called for floating-point modes in some
cases.  In 4.3-based sources I observed it being called from
simplify_set when loading an SFmode value, resulting in zero_extend:DI
of such a value - zero_extend of a floating-point value not being
well-defined.  In turn simplify_const_unary_operation ICEd on an
operation it was not expecting for floating-point modes.  The test, on
MIPS N64 soft-float, was from the glibc testsuite and reduced to:

extern float cf (float _Complex);
static float p, m;

void
c (void)
{
  _Complex float r, r2;
  __real__ r = p;
  __imag__ r = 1.0;
  cf (r);

  __real__ r2 = m;
  __imag__ r2 = 1.0;
  cf (r2);
}

but I do not have a test showing an ICE for FSF sources.  I did
however verify that if I add (in FSF sources) an assert to
simplify_set that the mode is an integer mode in the case where
LOAD_EXTEND_OP would be called, the assert triggered while building
libgcc.

This patch avoids calling LOAD_EXTEND_OP for non-integer modes in the
particular case where I observed this problem (I suspect it may arise
in other cases as well).  Tested with no regressions with cross to
mips64octeon-linux-gnu.  OK to commit?

2008-10-12  Joseph Myers  <joseph@codesourcery.com>

	* combine.c (simplify_set): Avoid calling LOAD_EXTEND_OP on
	non-integer modes.

Index: gcc/combine.c
===================================================================
--- gcc/combine.c	(revision 141048)
+++ gcc/combine.c	(working copy)
@@ -5843,6 +5843,7 @@
      zero_extend to avoid the reload that would otherwise be required.  */
 
   if (GET_CODE (src) == SUBREG && subreg_lowpart_p (src)
+      && GET_MODE_CLASS (GET_MODE (SUBREG_REG (src))) == MODE_INT
       && LOAD_EXTEND_OP (GET_MODE (SUBREG_REG (src))) != UNKNOWN
       && SUBREG_BYTE (src) == 0
       && (GET_MODE_SIZE (GET_MODE (src))

-- 
Joseph S. Myers
joseph@codesourcery.com


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