This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Committed] PR28131: type_for_mode langhook may return NULL_TREE
- From: Roger Sayle <roger at eyesopen dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: John David Anglin <dave dot anglin at nrc-cnrc dot gc dot ca>
- Date: Thu, 22 Jun 2006 19:42:51 -0600 (MDT)
- Subject: [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
--