From 84ece8efd21ed73d98de62e4bcf22b4160cd7faa Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Sat, 21 Apr 2007 17:47:13 +0000 Subject: [PATCH] re PR tree-optimization/31136 (FRE ignores bit-field truncation (C and C++ front-end don't produce bit-field truncation) 2007-04-21 Richard Guenther PR middle-end/31136 * fold-const.c (fold_unary): Call fold_convert_const on the original tree. * gcc.c-torture/execute/pr31136.c: New testcase. From-SVN: r124020 --- gcc/ChangeLog | 6 ++++++ gcc/fold-const.c | 2 +- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.c-torture/execute/pr31136.c | 17 +++++++++++++++++ 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.c-torture/execute/pr31136.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index cc3d7ab3943..034936d2105 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2007-04-21 Richard Guenther + + PR middle-end/31136 + * fold-const.c (fold_unary): Call fold_convert_const on the + original tree. + 2007-04-21 Alexandre Oliva * gcse.c (store_killed_in_insn): Handle PARALLELs. diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 6d2db7b876e..4e8f34f06ec 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -7857,7 +7857,7 @@ fold_unary (enum tree_code code, tree type, tree op0) return fold_build1 (BIT_NOT_EXPR, type, fold_convert (type, tem)); } - tem = fold_convert_const (code, type, arg0); + tem = fold_convert_const (code, type, op0); return tem ? tem : NULL_TREE; case VIEW_CONVERT_EXPR: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 00af7d42765..3157d85de1d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-04-21 Richard Guenther + + PR middle-end/31136 + * gcc.c-torture/execute/pr31136.c: New testcase. + 2007-04-21 Alexandre Oliva * gcc.target/i386/movsi-sm-1.c: New. diff --git a/gcc/testsuite/gcc.c-torture/execute/pr31136.c b/gcc/testsuite/gcc.c-torture/execute/pr31136.c new file mode 100644 index 00000000000..66c202c8fd3 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr31136.c @@ -0,0 +1,17 @@ +extern void abort (void); + +struct S { + unsigned b4:4; + unsigned b6:6; +} s; + +int main() +{ + s.b6 = 31; + s.b4 = s.b6; + s.b6 = s.b4; + if (s.b6 != 15) + abort (); + return 0; +} +