So I managed to re-introduce PR41043 by implementing the
fold_unary (T1)(X * Y) -> (T1)X * (T1)Y pattern on GIMPLE.
That is because it re-applies recursively on a large
multiplication tree and because if there are multiple uses
of SSA names doing that will expand (aka un-CSE) the
multiplication tree.  Oops.  The following restricts it
to at most one SSA name or two single-use SSA names.
In the end this kind of demotion should be done by a
pass, not by expression simplification (it's not really
a simplification after all).

Applied.

Richard.

2014-09-11  Richard Biener  <rguent...@suse.de>

        PR middle-end/41043
        * match-conversions.pd ((T1)(X * Y) -> (T1)X * (T1)Y): Restrict
        to a single or single-use SSA names.

Index: gcc/match-conversions.pd
===================================================================
--- gcc/match-conversions.pd    (revision 215110)
+++ gcc/match-conversions.pd    (working copy)
@@ -56,7 +56,15 @@
  (convert (mult @0 @1))
  (if (INTEGRAL_TYPE_P (type)
       && INTEGRAL_TYPE_P (TREE_TYPE (@0))
-      && TYPE_PRECISION (type) < TYPE_PRECISION (TREE_TYPE (@0)))
+      && TYPE_PRECISION (type) < TYPE_PRECISION (TREE_TYPE (@0))
+      /* ???  These kind of patterns are a bad idea - see PR41043.  We
+        create a lot of redundant statements if operands are used multiple
+        times.  Maybe we want a flag for this.  But eventually these
+        kind of transforms should be done in a pass.  */
+      && (GENERIC
+          || TREE_CODE (@0) != SSA_NAME || TREE_CODE (@1) != SSA_NAME
+         || ((TREE_CODE (@0) != SSA_NAME || has_single_use (@0))
+              && (TREE_CODE (@1) != SSA_NAME || has_single_use (@1)))))
   (if (TYPE_OVERFLOW_WRAPS (type))
    (mult (convert @0) (convert @1)))
   (with { tree utype = unsigned_type_for (type); }

Reply via email to