]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/56493 (Performance regression in google dense hashmap)
authorJakub Jelinek <jakub@redhat.com>
Thu, 4 Dec 2014 09:48:54 +0000 (10:48 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 4 Dec 2014 09:48:54 +0000 (10:48 +0100)
PR c++/56493
* convert.c (convert_to_real, convert_to_expr, convert_to_complex):
Handle COMPOUND_EXPR.

* c-c++-common/pr56493.c: New test.

From-SVN: r218347

gcc/ChangeLog
gcc/convert.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/pr56493.c [new file with mode: 0644]

index 4c533250434a73646f947ff1825e3041bd004520..da6e1602b4961ca1bf4773e7664a9fd960ce282a 100644 (file)
@@ -1,3 +1,9 @@
+2014-12-04  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/56493
+       * convert.c (convert_to_real, convert_to_expr, convert_to_complex):
+       Handle COMPOUND_EXPR.
+
 2014-12-02  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
        PR target/64115
index e124e7a7d472b9d46ca96197ca6251ff44509579..2b93437e5ea6f157ec2e4113d32eb0bc28a10945 100644 (file)
@@ -95,6 +95,15 @@ convert_to_real (tree type, tree expr)
   enum built_in_function fcode = builtin_mathfn_code (expr);
   tree itype = TREE_TYPE (expr);
 
+  if (TREE_CODE (expr) == COMPOUND_EXPR)
+    {
+      tree t = convert_to_real (type, TREE_OPERAND (expr, 1));
+      if (t == TREE_OPERAND (expr, 1))
+       return expr;
+      return build2_loc (EXPR_LOCATION (expr), COMPOUND_EXPR, TREE_TYPE (t),
+                        TREE_OPERAND (expr, 0), t);
+    }    
+
   /* Disable until we figure out how to decide whether the functions are
      present in runtime.  */
   /* Convert (float)sqrt((double)x) where x is float into sqrtf(x) */
@@ -366,6 +375,15 @@ convert_to_integer (tree type, tree expr)
       return error_mark_node;
     }
 
+  if (ex_form == COMPOUND_EXPR)
+    {
+      tree t = convert_to_integer (type, TREE_OPERAND (expr, 1));
+      if (t == TREE_OPERAND (expr, 1))
+       return expr;
+      return build2_loc (EXPR_LOCATION (expr), COMPOUND_EXPR, TREE_TYPE (t),
+                        TREE_OPERAND (expr, 0), t);
+    }    
+
   /* Convert e.g. (long)round(d) -> lround(d).  */
   /* If we're converting to char, we may encounter differing behavior
      between converting from double->char vs double->long->char.
@@ -854,6 +872,14 @@ convert_to_complex (tree type, tree expr)
 
        if (TYPE_MAIN_VARIANT (elt_type) == TYPE_MAIN_VARIANT (subtype))
          return expr;
+       else if (TREE_CODE (expr) == COMPOUND_EXPR)
+         {
+           tree t = convert_to_complex (type, TREE_OPERAND (expr, 1));
+           if (t == TREE_OPERAND (expr, 1))
+             return expr;
+           return build2_loc (EXPR_LOCATION (expr), COMPOUND_EXPR,
+                              TREE_TYPE (t), TREE_OPERAND (expr, 0), t);
+         }    
        else if (TREE_CODE (expr) == COMPLEX_EXPR)
          return fold_build2 (COMPLEX_EXPR, type,
                              convert (subtype, TREE_OPERAND (expr, 0)),
index 714d3f94d7630f008174137ba4ff12a153cfa571..8ff5be79e07db53882f70faa5b3d8ad44c8f739e 100644 (file)
@@ -1,3 +1,8 @@
+2014-12-04  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/56493
+       * c-c++-common/pr56493.c: New test.
+
 2014-11-28  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
diff --git a/gcc/testsuite/c-c++-common/pr56493.c b/gcc/testsuite/c-c++-common/pr56493.c
new file mode 100644 (file)
index 0000000..4181260
--- /dev/null
@@ -0,0 +1,16 @@
+/* PR c++/56493 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-gimple" } */
+
+unsigned long long bar (void);
+int x;
+
+void
+foo (void)
+{
+  x += bar ();
+}
+
+/* Verify we narrow the addition from unsigned long long to unsigned int type.  */
+/* { dg-final { scan-tree-dump "  (\[a-zA-Z._0-9]*) = \\(unsigned int\\) \[^;\n\r]*;.*  (\[a-zA-Z._0-9]*) = \\(unsigned int\\) \[^;\n\r]*;.* = \\1 \\+ \\2;" "gimple" { target { ilp32 || lp64 } } } } */
+/* { dg-final { cleanup-tree-dump "gimple" } } */