This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR84873
- From: Richard Biener <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Jakub Jelinek <jakub at redhat dot com>
- Date: Thu, 15 Mar 2018 13:56:16 +0100 (CET)
- Subject: [PATCH] Fix PR84873
The following fixes the C familiy gimplification langhook to not
introduce tree sharing which isn't valid during gimplification.
For the specific case the tree sharing is introduced by
fold_binary_op_with_cond and is reached via convert () eventually
folding something. I've kept folding constants here but for the
rest defer folding to GIMPLE (the gimplifier already folds most
generated stmts).
Bootstrapped and tested on x86_64-unknown-linux-gnu, ok for trunk and
branches?
Thanks,
Richard.
2018-03-15 Richard Biener <rguenther@suse.de>
PR c/84873
* c-gimplify.c (c_gimplify_expr): Do not fold expressions.
* c-c++-common/pr84873.c: New testcase.
Index: gcc/c-family/c-gimplify.c
===================================================================
--- gcc/c-family/c-gimplify.c (revision 258552)
+++ gcc/c-family/c-gimplify.c (working copy)
@@ -245,7 +245,15 @@ c_gimplify_expr (tree *expr_p, gimple_se
unsigned_type_node)
&& !types_compatible_p (TYPE_MAIN_VARIANT (TREE_TYPE (*op1_p)),
integer_type_node))
- *op1_p = convert (unsigned_type_node, *op1_p);
+ {
+ /* ??? Do not use convert () here or fold arbitrary trees
+ since folding can introduce tree sharing which is not
+ allowed during gimplification. */
+ if (TREE_CODE (*op1_p) == INTEGER_CST)
+ *op1_p = fold_convert (unsigned_type_node, *op1_p);
+ else
+ *op1_p = build1 (NOP_EXPR, unsigned_type_node, *op1_p);
+ }
break;
}
Index: gcc/testsuite/c-c++-common/pr84873.c
===================================================================
--- gcc/testsuite/c-c++-common/pr84873.c (nonexistent)
+++ gcc/testsuite/c-c++-common/pr84873.c (working copy)
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-frounding-math" } */
+
+int
+i1 (int w3, int n9)
+{
+ return w3 >> ((long int)(1 + 0.1) + -!n9);
+}