From 62fc1d7d18d061f34e73957b3e87511fdc5de3ba Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Tue, 17 Aug 2004 07:40:22 +0000 Subject: [PATCH] re PR middle-end/17036 (ICE: (A >> N) & 1 ? (1 << N) : 0 where A of type unsigned int) gcc/ChangeLog: 2004-08-17 Paolo Bonzini PR middle-end/17036 * fold-const.c (fold): Check for integer operand when folding (A >> N) & 1 ? (1 << N) : 0. Fix from Andrew Pinski . gcc/testsuite/ChangeLog: 2004-08-17 Paolo Bonzini * gcc.dg/pr17036-1.c: New test. From-SVN: r86112 --- gcc/ChangeLog | 10 ++++++++-- gcc/fold-const.c | 1 + gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.dg/pr17036-1.c | 11 +++++++++++ 4 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr17036-1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7f581a9f4b4..ece9c7b89c3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2004-08-17 Paolo Bonzini + + PR middle-end/17036 + * fold-const.c (fold): Check for integer operand when + folding (A >> N) & 1 ? (1 << N) : 0. Fix from Andrew + Pinski . + 2004-08-17 Paolo Bonzini * configure.ac: Trust toplevel's notion of BISON/FLEX/MAKEINFO. @@ -131,10 +138,9 @@ 2004-08-16 Nathanael Nerode * tree-ssa-copyrename.c (copy_rename_partition_coalesce): - Check for arificial variables, not is_gimple_tmp_var. + Check for artificial variables, not is_gimple_tmp_var. * tree-ssa-live.c (var_union): Likewise. ->>>>>>> 2.4930 2004-08-16 Nathan Sidwell * calls.c (load_register_parameters): Remove spurious FIXME token. diff --git a/gcc/fold-const.c b/gcc/fold-const.c index c404613f842..319e455f433 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -8859,6 +8859,7 @@ fold (tree expr) tree tem = TREE_OPERAND (arg0, 0); STRIP_NOPS (tem); if (TREE_CODE (tem) == RSHIFT_EXPR + && TREE_CODE (TREE_OPERAND (tem, 1)) == INTEGER_CST && (unsigned HOST_WIDE_INT) tree_log2 (arg1) == TREE_INT_CST_LOW (TREE_OPERAND (tem, 1))) return fold (build2 (BIT_AND_EXPR, type, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 319fe1da9ec..0f65b738180 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2004-08-17 Paolo Bonzini + + * gcc.dg/pr17036-1.c: New test. + 2004-08-16 Devang Patel * gcc.dg/darwin-20040809-1.c: New test. diff --git a/gcc/testsuite/gcc.dg/pr17036-1.c b/gcc/testsuite/gcc.dg/pr17036-1.c new file mode 100644 index 00000000000..ea2c9caf6f9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr17036-1.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ + +int main () +{ + int R, N = 4; + unsigned int A = 2; + signed int B = 2; + ((B >> N) & 1) ? 1 : 0; + ((A >> N) & 1) ? 1 : 0; + return 0; +} -- 2.30.2