]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Backport r251530
authorMartin Liska <mliska@suse.cz>
Fri, 15 Sep 2017 09:21:42 +0000 (11:21 +0200)
committerMartin Liska <marxin@gcc.gnu.org>
Fri, 15 Sep 2017 09:21:42 +0000 (09:21 +0000)
2017-09-15  Martin Liska  <mliska@suse.cz>

Backport from mainline
2017-08-30  Martin Liska  <mliska@suse.cz>

PR inline-asm/82001
* ipa-icf-gimple.c (func_checker::compare_tree_list_operand):
Rename to ...
(func_checker::compare_asm_inputs_outputs): ... this function.
(func_checker::compare_gimple_asm): Use the function to compare
also ASM constrains.
* ipa-icf-gimple.h: Rename the function.
2017-09-15  Martin Liska  <mliska@suse.cz>

Backport from mainline
2017-08-30  Martin Liska  <mliska@suse.cz>

PR inline-asm/82001
* gcc.dg/ipa/pr82001.c: New test.

From-SVN: r252799

gcc/ChangeLog
gcc/ipa-icf-gimple.c
gcc/ipa-icf-gimple.h
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/ipa/pr82001.c [new file with mode: 0644]

index 04ce65b0ccdd3e4ebb5b69f018e33b1a217460f0..3753eeb1267f9779ea805c53e391bde60d663d5f 100644 (file)
@@ -1,3 +1,16 @@
+2017-09-15  Martin Liska  <mliska@suse.cz>
+
+       Backport from mainline
+       2017-08-30  Martin Liska  <mliska@suse.cz>
+
+       PR inline-asm/82001
+       * ipa-icf-gimple.c (func_checker::compare_tree_list_operand):
+       Rename to ...
+       (func_checker::compare_asm_inputs_outputs): ... this function.
+       (func_checker::compare_gimple_asm): Use the function to compare
+       also ASM constrains.
+       * ipa-icf-gimple.h: Rename the function.
+
 2017-09-15  Martin Liska  <mliska@suse.cz>
 
        Backport from mainline
index 1c5aebf00ca3a6c7e6dcd430341360b89b8ff4b5..9a9012c6983ea16736ee01dacfe0151bf893d0a1 100644 (file)
@@ -543,11 +543,8 @@ func_checker::compare_operand (tree t1, tree t2)
     }
 }
 
-/* Compares two tree list operands T1 and T2 and returns true if these
-   two trees are semantically equivalent.  */
-
 bool
-func_checker::compare_tree_list_operand (tree t1, tree t2)
+func_checker::compare_asm_inputs_outputs (tree t1, tree t2)
 {
   gcc_assert (TREE_CODE (t1) == TREE_LIST);
   gcc_assert (TREE_CODE (t2) == TREE_LIST);
@@ -560,6 +557,16 @@ func_checker::compare_tree_list_operand (tree t1, tree t2)
       if (!compare_operand (TREE_VALUE (t1), TREE_VALUE (t2)))
        return return_false ();
 
+      tree p1 = TREE_PURPOSE (t1);
+      tree p2 = TREE_PURPOSE (t2);
+
+      gcc_assert (TREE_CODE (p1) == TREE_LIST);
+      gcc_assert (TREE_CODE (p2) == TREE_LIST);
+
+      if (strcmp (TREE_STRING_POINTER (TREE_VALUE (p1)),
+                 TREE_STRING_POINTER (TREE_VALUE (p2))) != 0)
+       return return_false ();
+
       t2 = TREE_CHAIN (t2);
     }
 
@@ -1008,7 +1015,7 @@ func_checker::compare_gimple_asm (const gasm *g1, const gasm *g2)
       tree input1 = gimple_asm_input_op (g1, i);
       tree input2 = gimple_asm_input_op (g2, i);
 
-      if (!compare_tree_list_operand (input1, input2))
+      if (!compare_asm_inputs_outputs (input1, input2))
        return return_false_with_msg ("ASM input is different");
     }
 
@@ -1017,7 +1024,7 @@ func_checker::compare_gimple_asm (const gasm *g1, const gasm *g2)
       tree output1 = gimple_asm_output_op (g1, i);
       tree output2 = gimple_asm_output_op (g2, i);
 
-      if (!compare_tree_list_operand (output1, output2))
+      if (!compare_asm_inputs_outputs (output1, output2))
        return return_false_with_msg ("ASM output is different");
     }
 
index 9530a8ed55cddd3ab20a3260fdf23200839ea93a..c572a181736121a754532fe5e1178682f42edd33 100644 (file)
@@ -215,9 +215,9 @@ public:
      is returned.  */
   bool compare_operand (tree t1, tree t2);
 
-  /* Compares two tree list operands T1 and T2 and returns true if these
-     two trees are semantically equivalent.  */
-  bool compare_tree_list_operand (tree t1, tree t2);
+  /* Compares GIMPLE ASM inputs (or outputs) where we iterate tree chain
+     and compare both TREE_PURPOSEs and TREE_VALUEs.  */
+  bool compare_asm_inputs_outputs (tree t1, tree t2);
 
   /* Verifies that trees T1 and T2, representing function declarations
      are equivalent from perspective of ICF.  */
index 36c92edbf3f90b115a3bac7419164ce0046f0822..504d5dac28d3d27a73cf70ed37d08eba21aa93c1 100644 (file)
@@ -1,3 +1,11 @@
+2017-09-15  Martin Liska  <mliska@suse.cz>
+
+       Backport from mainline
+       2017-08-30  Martin Liska  <mliska@suse.cz>
+
+       PR inline-asm/82001
+       * gcc.dg/ipa/pr82001.c: New test.
+
 2017-09-15  Martin Liska  <mliska@suse.cz>
 
        Backport from mainline
diff --git a/gcc/testsuite/gcc.dg/ipa/pr82001.c b/gcc/testsuite/gcc.dg/ipa/pr82001.c
new file mode 100644 (file)
index 0000000..05e32b1
--- /dev/null
@@ -0,0 +1,21 @@
+/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "-O2 -fdump-ipa-icf-details"  } */
+
+int
+mullo (int a, int b)
+{
+  asm("mul %%edx   # %%1 was %1"
+      : "+"
+       "a"(a),
+       "+d"(b));
+  return a;
+}
+
+int
+mulhi (int a, int b)
+{
+  asm("mul %%edx   # %%1 was %1" : "+d"(a), "+a"(b));
+  return a;
+}
+
+/* { dg-final { scan-ipa-dump "Equal symbols: 0" "icf"  } } */