From 8cce3d04c451595cc9f33a332a4dbeae2729b40e Mon Sep 17 00:00:00 2001 From: Roger Sayle Date: Sat, 20 Mar 2004 23:03:03 +0000 Subject: [PATCH] re PR target/13889 (Assignment of an int to an int of different size in a struct gives ICE) PR target/13889 * cse.c (fold_rtx): Avoid substituting constants into unary convertion operations. * gcc.c-torture/compile/pr13889.c: New test case. From-SVN: r79762 --- gcc/ChangeLog | 6 ++++++ gcc/cse.c | 17 +++++++++++++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.c-torture/compile/pr13889.c | 7 +++++++ 4 files changed, 35 insertions(+) create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr13889.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f3de3ff54c5..ccbe122132a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2004-03-20 Roger Sayle + + PR target/13889 + * cse.c (fold_rtx): Avoid substituting constants into unary + convertion operations. + 2004-03-20 Kazu Hirata * fold-const.c (fold): Replace "expr" with "t". diff --git a/gcc/cse.c b/gcc/cse.c index 9e4cab8cd90..38f6ef06004 100644 --- a/gcc/cse.c +++ b/gcc/cse.c @@ -3662,6 +3662,23 @@ fold_rtx (rtx x, rtx insn) || (new_cost == old_cost && CONSTANT_P (XEXP (x, i)))) break; + /* It's not safe to substitute the operand of a conversion + operator with a constant, as the conversion's identity + depends upon the mode of it's operand. This optimization + is handled by the call to simplify_unary_operation. */ + if (GET_RTX_CLASS (code) == RTX_UNARY + && GET_MODE (replacements[j]) != mode_arg0 + && (code == ZERO_EXTEND + || code == SIGN_EXTEND + || code == TRUNCATE + || code == FLOAT_TRUNCATE + || code == FLOAT_EXTEND + || code == FLOAT + || code == FIX + || code == UNSIGNED_FLOAT + || code == UNSIGNED_FIX)) + continue; + if (validate_change (insn, &XEXP (x, i), replacements[j], 0)) break; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index dc7239bc0d6..b53e941f162 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-03-20 Roger Sayle + + PR target/13889 + * gcc.c-torture/compile/pr13889.c: New test case. + 2004-03-20 Joseph S. Myers PR c/14635 diff --git a/gcc/testsuite/gcc.c-torture/compile/pr13889.c b/gcc/testsuite/gcc.c-torture/compile/pr13889.c new file mode 100644 index 00000000000..d14bc9ac542 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr13889.c @@ -0,0 +1,7 @@ +/* PR target/13889 */ +struct { long long a; } *p; +void initNetFlowFunct(void) { + unsigned int b = (unsigned int)-1; + p->a = b; +} + -- 2.30.2