Fix to gen_lowpart_for_combine; resolves PR 4579

Matt Hiller hiller@redhat.com
Wed Jan 2 19:23:00 GMT 2002


	The included testcase in current CVS (when run at -O1 or higher
with -m3dnow) will trigger an abort, when combine tries to simplify the
rtx (subreg:V2SF (const_int 1 [0x1]) 0). The included patch fixes this
abort; no testsuite regressions (though I did not do a full bootstrap.)
Okay to apply?

	I'll send in a patch for adding the testcase to the testsuite once
I figure out how best to do this (i.e., only when the target is x86.)

#include <stdio.h>
typedef __v2sf __attribute__ ((mode (V2SF)));

int
main (int argc, char *argv[])
{
  __v2sf a, b;
  long long g;
  g=1;
  a = (__v2sf) g;
  b = a;
  b = __builtin_ia32_pfadd (a, b);
  g = (long long) b;
  if (g == 0)
    printf ("\n");
  return 0;
}

2002-01-02  Matthew Hiller  <hiller@redhat.com>

	* combine.c (gen_lowpart_for_combine): In fallthru case, check
	that x's mode is not VOIDmode before calling simplify_gen_subreg.

Index: gcc/combine.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/combine.c,v
retrieving revision 1.249
diff -c -p -r1.249 combine.c
*** combine.c	2001/12/28 07:52:44	1.249
--- combine.c	2002/01/03 02:48:31
*************** gen_lowpart_for_combine (mode, x)
*** 9774,9786 ****
       include an explicit SUBREG or we may simplify it further in combine.  */
    else
      {
!       int offset = 0;
!       rtx res;
  
!       offset = subreg_lowpart_offset (mode, GET_MODE (x));
!       res = simplify_gen_subreg (mode, x, GET_MODE (x), offset);
!       if (res)
! 	return res;
        return gen_rtx_CLOBBER (GET_MODE (x), const0_rtx);
      }
  }
--- 9774,9791 ----
       include an explicit SUBREG or we may simplify it further in combine.  */
    else
      {
!       /* Check to see if x's mode is VOIDmode before calling
! 	 simplify_gen_subreg.  In gcc PR 4579, mode was V2SFmode and x
! 	 was const1_rtx; execution would abort in this call.  */
  
!       if (GET_MODE (x) != VOIDmode)
! 	{
! 	  int offset = subreg_lowpart_offset (mode, GET_MODE (x));
! 	  rtx res = simplify_gen_subreg (mode, x, GET_MODE (x), offset);
! 
! 	  if (res)
! 	    return res;
! 	}
        return gen_rtx_CLOBBER (GET_MODE (x), const0_rtx);
      }
  }



More information about the Gcc-patches mailing list