public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-5392] Fix tree-optimization/103257: Missed jump threading due too early conversion of bool*A into bool?A:0
@ 2021-11-19  6:41 Andrew Pinski
  0 siblings, 0 replies; only message in thread
From: Andrew Pinski @ 2021-11-19  6:41 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:527e54a431473cc497204226a21f2831d2375e66

commit r12-5392-g527e54a431473cc497204226a21f2831d2375e66
Author: Andrew Pinski <apinski@marvell.com>
Date:   Tue Nov 16 04:46:21 2021 +0000

    Fix tree-optimization/103257: Missed jump threading due too early conversion of bool*A into bool?A:0
    
    So like many optimizations on the gimple level, sometimes it makes sense to do the
    optimization early or later. In this case, creating a cond expression early causes
    other optimizations to be missed.  So just disable it until canonicalize_math_p ()
    is false.
    
    OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.
    
            PR tree-optimization/103257
    
    gcc/ChangeLog:
    
            * match.pd
            ((m1 >/</>=/<= m2) * d -> (m1 >/</>=/<= m2) ? d : 0):
            Disable until !canonicalize_math_p ().
    
    gcc/testsuite/ChangeLog:
    
            * gcc.dg/tree-ssa/vrp116.c: Check optimized instead of vrp1.
            * gcc.dg/tree-ssa/pr103257-1.c: New test.

Diff:
---
 gcc/match.pd                               |  8 ++++----
 gcc/testsuite/gcc.dg/tree-ssa/pr103257-1.c | 11 +++++++++++
 gcc/testsuite/gcc.dg/tree-ssa/vrp116.c     |  4 ++--
 3 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/gcc/match.pd b/gcc/match.pd
index 77d848d631e..4042b535b85 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -1785,10 +1785,10 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
   (convert (bit_and (bit_not @1) @0))))
 
 /* (m1 CMP m2) * d -> (m1 CMP m2) ? d : 0  */
-(for cmp (gt lt ge le)
-(simplify
- (mult (convert (cmp @0 @1)) @2)
-  (if (GIMPLE || !TREE_SIDE_EFFECTS (@2))
+(if (!canonicalize_math_p ())
+ (for cmp (gt lt ge le)
+  (simplify
+   (mult (convert (cmp @0 @1)) @2)
    (cond (cmp @0 @1) @2 { build_zero_cst (type); }))))
 
 /* For integral types with undefined overflow and C != 0 fold
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr103257-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr103257-1.c
new file mode 100644
index 00000000000..89f4f44b06c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr103257-1.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+void link_error(void);
+unsigned b, c;
+static short a(short e, short f) { return e * f; }
+int main() {
+  if (a(1  ^ ((0, 0) ^ 1 && b) <= b, c))
+    link_error ();
+  c = 0;
+}
+/* { dg-final { scan-tree-dump-times "link_error" 0 "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp116.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp116.c
index d9d7b2394cd..9e68a774aee 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/vrp116.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp116.c
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-vrp1" } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
 
 int
 f (int m1, int m2, int c)
@@ -9,4 +9,4 @@ f (int m1, int m2, int c)
   return e ? m1 : m2;
 }
 
-/* { dg-final { scan-tree-dump-times "\\? c_\[0-9\]\\(D\\) : 0" 1 "vrp1" } } */
+/* { dg-final { scan-tree-dump-times "\\? c_\[0-9\]\\(D\\) : 0" 1 "optimized" } } */


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-11-19  6:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-19  6:41 [gcc r12-5392] Fix tree-optimization/103257: Missed jump threading due too early conversion of bool*A into bool?A:0 Andrew Pinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).