This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix PR31096
- From: "Hurugalawadi, Naveen" <Naveen dot Hurugalawadi at caviumnetworks dot com>
- To: "marc dot glisse at inria dot fr" <marc dot glisse at inria dot fr>, "ramana dot radhakrishnan at foss dot arm dot com" <ramana dot radhakrishnan at foss dot arm dot com>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 5 Apr 2016 09:09:08 +0000
- Subject: Re: [PATCH] Fix PR31096
- Authentication-results: sourceware.org; auth=none
- Authentication-results: gcc.gnu.org; dkim=none (message not signed) header.d=none;gcc.gnu.org; dmarc=none action=none header.from=caviumnetworks.com;
- References: <SN2PR0701MB102491E5EF1A9EE96C8619688E990 at SN2PR0701MB1024 dot namprd07 dot prod dot outlook dot com>,<alpine dot DEB dot 2 dot 20 dot 1603311120300 dot 1831 at laptop-mg dot saclay dot inria dot fr>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:23
Hi,
>> Looks like you are turning x*-1 < y*-1 into x<y? That doesn't work...
Please find attached the modified patch that works on integer
constant values.
Please review the patch and let me know if this is okay?
Thanks,
Naveen
diff --git a/gcc/match.pd b/gcc/match.pd
index c0ed305..e073e9f 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -894,7 +894,11 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
&& tree_nop_conversion_p (type, TREE_TYPE (@1)))
(convert (bit_and (bit_not @1) @0))))
-
+/* Fold A * 10 == B * 10 into A == B. naveen*/
+(for cmp (tcc_comparison)
+ (simplify
+ (cmp (mult:cs @0 INTEGER_CST@1) (mult:cs @2 INTEGER_CST@1))
+ (cmp @0 @2)))
/* ((X inner_op C0) outer_op C1)
With X being a tree where value_range has reasoned certain bits to always be
diff --git a/gcc/testsuite/gcc.dg/pr31096.c b/gcc/testsuite/gcc.dg/pr31096.c
new file mode 100644
index 0000000..1c464db
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr31096.c
@@ -0,0 +1,17 @@
+/* PR middle-end/31096 */
+/* { dg-do compile } */
+/* { dg-options "-O1 -fdump-tree-optimized" } */
+
+int
+f (int a, int b)
+{
+ return a * 10 == b * 10;
+}
+
+int
+f1 (int a, int b)
+{
+ return a == b;
+}
+
+/* { dg-final { scan-tree-dump-not " * 10" "optimized" } } */