Complex issues

Jeffrey A Law law@cygnus.com
Wed Jul 14 23:06:00 GMT 1999


This patch causes the compiler to generate a fatal error instead of silently
generating incorrect code for certain accesses to components of complex
numbers.

Index: emit-rtl.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/emit-rtl.c,v
retrieving revision 1.59.4.2
diff -c -3 -p -r1.59.4.2 emit-rtl.c
*** emit-rtl.c	1999/06/21 17:52:02	1.59.4.2
--- emit-rtl.c	1999/07/15 06:02:43
*************** gen_realpart (mode, x)
*** 966,971 ****
--- 966,976 ----
  {
    if (GET_CODE (x) == CONCAT && GET_MODE (XEXP (x, 0)) == mode)
      return XEXP (x, 0);
+   else if (WORDS_BIG_ENDIAN
+ 	   && GET_MODE_BITSIZE (mode) < BITS_PER_WORD
+ 	   && REG_P (x)
+ 	   && REGNO (x) < FIRST_PSEUDO_REGISTER)
+     fatal ("Unable to access real part of complex value in a hard register 
on this target");
    else if (WORDS_BIG_ENDIAN)
      return gen_highpart (mode, x);
    else
*************** gen_imagpart (mode, x)
*** 984,989 ****
--- 989,999 ----
      return XEXP (x, 1);
    else if (WORDS_BIG_ENDIAN)
      return gen_lowpart (mode, x);
+   else if (!WORDS_BIG_ENDIAN
+ 	   && GET_MODE_BITSIZE (mode) < BITS_PER_WORD
+ 	   && REG_P (x)
+ 	   && REGNO (x) < FIRST_PSEUDO_REGISTER)
+     fatal ("Unable to access imaginary part of complex value in a hard 
register on this target");
    else
      return gen_highpart (mode, x);
  }





More information about the Gcc-patches mailing list