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]

[PATCH] Fix ICE in convert_move expanding V_C_E via store-flag


When expanding the V_C_E of the comparison result in the testcase below
we end up calling do_store_flag for an integer comparison with
SFmode target mode.  This isn't going to work and probably was never
intended to.  The following avoids the situation.

Bootstrapped and tested on x86_64-unknown-linux-gnu, ok?

Thanks,
Richard.

Index: gcc/expr.c
===================================================================
*** gcc/expr.c	(revision 147659)
--- gcc/expr.c	(working copy)
*************** expand_expr_real_1 (tree exp, rtx target
*** 9042,9050 ****
      case LTGT_EXPR:
        temp = do_store_flag (exp,
  			    modifier != EXPAND_STACK_PARM ? target : NULL_RTX,
! 			    tmode != VOIDmode ? tmode : mode);
        if (temp != 0)
! 	return temp;
  
        /* For foo != 0, load foo, and if it is nonzero load 1 instead.  */
        if (code == NE_EXPR && integer_zerop (TREE_OPERAND (exp, 1))
--- 9042,9060 ----
      case LTGT_EXPR:
        temp = do_store_flag (exp,
  			    modifier != EXPAND_STACK_PARM ? target : NULL_RTX,
! 			    (tmode != VOIDmode
! 			     && GET_MODE_CLASS (tmode) == GET_MODE_CLASS (mode))
! 			    ? tmode : mode);
        if (temp != 0)
! 	{
! 	  /* If we have a mode-change that convert_move cannot handle
! 	     we called do_store_flag with the target mode of the comparison.
! 	     Fix that here.  */
! 	  if (tmode != VOIDmode
! 	      && GET_MODE_CLASS (tmode) != GET_MODE_CLASS (mode))
! 	    temp = simplify_gen_subreg (tmode, temp, mode, 0);
! 	  return temp;
! 	}
  
        /* For foo != 0, load foo, and if it is nonzero load 1 instead.  */
        if (code == NE_EXPR && integer_zerop (TREE_OPERAND (exp, 1))
Index: gcc/testsuite/gcc.c-torture/compile/20090518-1.c
===================================================================
*** gcc/testsuite/gcc.c-torture/compile/20090518-1.c	(revision 0)
--- gcc/testsuite/gcc.c-torture/compile/20090518-1.c	(revision 0)
***************
*** 0 ****
--- 1,6 ----
+ float
+ foo(int i)
+ {
+   int j = i == 42;
+   return *(float *)&j;
+ }


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