aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2017-09-15 12:14:19 +0000
committerMartin Liska <mliska@suse.cz>2017-09-15 12:14:19 +0000
commit5a9a435714a605ec6b39b59266f282dcdc25a44d (patch)
tree9b0d7696d6dc562ad2587757c8af8883a0dbd101
parentcd9cee12460d266d4c1e92b7aa5c579c5b446853 (diff)
Backport r251530
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. git-svn-id: https://gcc.gnu.org/svn/gcc/branches/gcc-5-branch@252812 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog13
-rw-r--r--gcc/ipa-icf-gimple.c19
-rw-r--r--gcc/ipa-icf-gimple.h6
-rw-r--r--gcc/testsuite/ChangeLog8
-rw-r--r--gcc/testsuite/gcc.dg/ipa/pr82001.c21
5 files changed, 58 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c028b6147fc..38cbf7dff75 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,6 +1,19 @@
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-10 Martin Liska <mliska@suse.cz>
PR c++/81355
diff --git a/gcc/ipa-icf-gimple.c b/gcc/ipa-icf-gimple.c
index 6227b7e9579..a97f282a7a2 100644
--- a/gcc/ipa-icf-gimple.c
+++ b/gcc/ipa-icf-gimple.c
@@ -577,11 +577,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);
@@ -594,6 +591,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);
}
@@ -1039,7 +1046,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");
}
@@ -1048,7 +1055,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");
}
diff --git a/gcc/ipa-icf-gimple.h b/gcc/ipa-icf-gimple.h
index 6a9cbed5ff4..4d2ec9169b7 100644
--- a/gcc/ipa-icf-gimple.h
+++ b/gcc/ipa-icf-gimple.h
@@ -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. */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index dd465052bc7..576064b4f2c 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,6 +1,14 @@
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
2017-08-10 Martin Liska <mliska@suse.cz>
PR c++/81355
diff --git a/gcc/testsuite/gcc.dg/ipa/pr82001.c b/gcc/testsuite/gcc.dg/ipa/pr82001.c
new file mode 100644
index 00000000000..05e32b10ef5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/pr82001.c
@@ -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" } } */