summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2007-10-08 15:23:49 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2007-10-08 15:23:49 +0000
commit984e8eccb522dedfa43b948106d2508c2ed4b645 (patch)
tree68d927f3aff3877ad0962683ab193ec9859c84fb /gcc
parent2605f523a5f1e362cae6701c4c11c031ea1259b5 (diff)
downloadgcc-984e8eccb522dedfa43b948106d2508c2ed4b645.tar.gz
2007-10-08 Richard Guenther <rguenther@suse.de>
PR middle-end/33693 PR middle-end/33695 PR middle-end/33697 * fold-const.c (fold_binary): Use correct types in folding of a * (1 << b) to (a << b). Likewise for ~A & ~B to ~(A | B) and building of RROTATE_EXPR. * gcc.dg/pr33693.c: New testcase. * gcc.dg/pr33695.c: Likewise. * gcc.dg/pr33697.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@129130 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/fold-const.c14
-rw-r--r--gcc/testsuite/ChangeLog9
-rw-r--r--gcc/testsuite/gcc.dg/pr33693.c8
-rw-r--r--gcc/testsuite/gcc.dg/pr33695.c8
-rw-r--r--gcc/testsuite/gcc.dg/pr33697.c10
6 files changed, 52 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index a54a60c868e..b03f6d0f589 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,14 @@
2007-10-08 Richard Guenther <rguenther@suse.de>
+ PR middle-end/33693
+ PR middle-end/33695
+ PR middle-end/33697
+ * fold-const.c (fold_binary): Use correct types in folding
+ of a * (1 << b) to (a << b). Likewise for ~A & ~B to ~(A | B)
+ and building of RROTATE_EXPR.
+
+2007-10-08 Richard Guenther <rguenther@suse.de>
+
PR middle-end/33691
PR middle-end/33694
PR middle-end/33696
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 0313c0ca840..4a8153cb499 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -10348,16 +10348,16 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
&& (tem = negate_expr (arg1)) != arg1
&& !TREE_OVERFLOW (tem))
return fold_build2 (MULT_EXPR, type,
- negate_expr (arg0), tem);
+ fold_convert (type, negate_expr (arg0)), tem);
/* (a * (1 << b)) is (a << b) */
if (TREE_CODE (arg1) == LSHIFT_EXPR
&& integer_onep (TREE_OPERAND (arg1, 0)))
- return fold_build2 (LSHIFT_EXPR, type, arg0,
+ return fold_build2 (LSHIFT_EXPR, type, op0,
TREE_OPERAND (arg1, 1));
if (TREE_CODE (arg0) == LSHIFT_EXPR
&& integer_onep (TREE_OPERAND (arg0, 0)))
- return fold_build2 (LSHIFT_EXPR, type, arg1,
+ return fold_build2 (LSHIFT_EXPR, type, op1,
TREE_OPERAND (arg0, 1));
strict_overflow_p = false;
@@ -11012,8 +11012,10 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
{
return fold_build1 (BIT_NOT_EXPR, type,
build2 (BIT_IOR_EXPR, type,
- TREE_OPERAND (arg0, 0),
- TREE_OPERAND (arg1, 0)));
+ fold_convert (type,
+ TREE_OPERAND (arg0, 0)),
+ fold_convert (type,
+ TREE_OPERAND (arg1, 0))));
}
/* If arg0 is derived from the address of an object or function, we may
@@ -11549,7 +11551,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
tree tem = build_int_cst (TREE_TYPE (arg1),
GET_MODE_BITSIZE (TYPE_MODE (type)));
tem = const_binop (MINUS_EXPR, tem, arg1, 0);
- return fold_build2 (RROTATE_EXPR, type, arg0, tem);
+ return fold_build2 (RROTATE_EXPR, type, op0, tem);
}
/* If we have a rotate of a bit operation with the rotate count and
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 9af8f71c4b5..f7fd6dd35b0 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,14 @@
2007-10-08 Richard Guenther <rguenther@suse.de>
+ PR middle-end/33693
+ PR middle-end/33695
+ PR middle-end/33697
+ * gcc.dg/pr33693.c: New testcase.
+ * gcc.dg/pr33695.c: Likewise.
+ * gcc.dg/pr33697.c: Likewise.
+
+2007-10-08 Richard Guenther <rguenther@suse.de>
+
PR middle-end/33691
PR middle-end/33694
PR middle-end/33696
diff --git a/gcc/testsuite/gcc.dg/pr33693.c b/gcc/testsuite/gcc.dg/pr33693.c
new file mode 100644
index 00000000000..147c164c4b4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr33693.c
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+
+/* This used to ICE with type-checking enabled. */
+
+unsigned long modify_field (unsigned long mask, long fieldval)
+{
+ return (~fieldval & ~mask);
+}
diff --git a/gcc/testsuite/gcc.dg/pr33695.c b/gcc/testsuite/gcc.dg/pr33695.c
new file mode 100644
index 00000000000..2d3ffbd6688
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr33695.c
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+
+/* We used to ICE with type-checking enabled. */
+
+unsigned int bfstages(int M, float *Utbl, int Ustride)
+{
+ return ((unsigned int) 1 << M) * Ustride;
+}
diff --git a/gcc/testsuite/gcc.dg/pr33697.c b/gcc/testsuite/gcc.dg/pr33697.c
new file mode 100644
index 00000000000..8c5edb65853
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr33697.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+
+/* We used to ICE for this with type-checking enabled. */
+
+typedef signed short gint16;
+typedef unsigned short guint16;
+gint16 dissect_old_pflog(gint16 rnr)
+{
+ return (guint16) ((guint16) ((guint16)rnr >> 8) | (guint16) ((guint16)rnr << 8));
+}