On Thu, Nov 03, 2016 at 04:03:22PM +0100, Dominik Vogt wrote:
> I've been trying to fix some bad tree-ssa related optimisation for
> s390x and come up with the attached experimental patch.  The patch
> is not really good - it breaks some situations in which the
> optimisation was useful.  With this code:
...

Missing patch attached.

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany
>From c1ee9d85c47ce66aa0b5c97739717fefcb07b4ce Mon Sep 17 00:00:00 2001
From: Dominik Vogt <v...@linux.vnet.ibm.com>
Date: Wed, 2 Nov 2016 14:01:46 +0100
Subject: [PATCH] Check number of uses in simplify_cond_using_ranges().

---
 gcc/tree-vrp.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index 3c75a0d..e74d935 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -9599,7 +9599,12 @@ simplify_cond_using_ranges (gcond *stmt)
                 with strict overflow semantics.  */
              && ((!is_negative_overflow_infinity (vr->min)
                   && !is_positive_overflow_infinity (vr->max))
-                 || TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (innerop))))
+                 || TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (innerop)))
+             /* If the only use of INNEROP is the cast to OP0, and OP0 is also
+                used in other places, folding would introduce new uses of the
+                otherwise dead INNEROP without eliminating OP0, so do not
+                fold.  */
+             && (!has_single_use (innerop) || has_single_use (op0)))
            {
              /* If the range overflowed and the user has asked for warnings
                 when strict overflow semantics were used to optimize code,
-- 
2.3.0

Reply via email to