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]

[Committed] PR28131: type_for_mode langhook may return NULL_TREE


The following patch should resolve PR middle-end/28131 which is an
ICE-on-valid regression on HPPA, resulting from my recent patch to
improve RTL expansion of VECTOR_CSTs.  My apologies for the fallout.
The issue is that on some front-end/back-end combinations the
type_for_mode langhook may potentially return NULL_TREE for some
backend scalar integer modes.  My patch didn't anticipate/protect
against this and blindly called "fold" with a NULL_TREE type.  The
obvious fix is to simply check that we managed to find a type before
calling fold.

The following patch has been tested on i686-pc-linux-gnu with a full
"make bootstrap", all default languages including Ada, and regression
tested with a top-level "make -k check" with no new failures.

Committed to mainline as revision 114923.



2006-06-22  Roger Sayle  <roger@eyesopen.com>
	    John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>

	PR middle-end/28131
	* expr.c (expand_expr_real_1) <VECTOR_CST>: Check whether the
	call to lang_hooks.types.type_for_mode returned NULL_TREE.


Index: expr.c
===================================================================
*** expr.c	(revision 114821)
--- expr.c	(working copy)
*************** expand_expr_real_1 (tree exp, rtx target
*** 6945,6953 ****
  	    || GET_MODE_CLASS (mode) == MODE_VECTOR_FLOAT)
  	  return const_vector_from_tree (exp);
  	if (GET_MODE_CLASS (mode) == MODE_INT)
! 	  tmp = fold_unary (VIEW_CONVERT_EXPR,
! 			    lang_hooks.types.type_for_mode (mode, 1),
! 			    exp);
  	if (!tmp)
  	  tmp = build_constructor_from_list (type,
  					     TREE_VECTOR_CST_ELTS (exp));
--- 6945,6955 ----
  	    || GET_MODE_CLASS (mode) == MODE_VECTOR_FLOAT)
  	  return const_vector_from_tree (exp);
  	if (GET_MODE_CLASS (mode) == MODE_INT)
! 	  {
! 	    tree type_for_mode = lang_hooks.types.type_for_mode (mode, 1);
! 	    if (type_for_mode)
! 	      tmp = fold_unary (VIEW_CONVERT_EXPR, type_for_mode, exp);
! 	  }
  	if (!tmp)
  	  tmp = build_constructor_from_list (type,
  					     TREE_VECTOR_CST_ELTS (exp));


Roger
--


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