[Bug tree-optimization/70251] Wrong code with -O3 -march=skylake-avx512.

ienkovich at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Mar 16 13:41:00 GMT 2016


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70251

--- Comment #2 from Ilya Enkovich <ienkovich at gcc dot gnu.org> ---
Here is a responsible match.pd pattern:

/* A + (B vcmp C ? 1 : 0) -> A - (B vcmp C), since vector comparisons
   return all-1 or all-0 results.  */
/* ??? We could instead convert all instances of the vec_cond to negate,
   but that isn't necessarily a win on its own.  */
(simplify
 (plus:c @3 (view_convert? (vec_cond @0 integer_each_onep@1 integer_zerop@2)))
 (if (VECTOR_TYPE_P (type)
      && TYPE_VECTOR_SUBPARTS (type) == TYPE_VECTOR_SUBPARTS (TREE_TYPE (@0))
      && (TYPE_MODE (TREE_TYPE (type))
          == TYPE_MODE (TREE_TYPE (TREE_TYPE (@0)))))
  (minus @3 (view_convert @0))))

I propose this patch:

diff --git a/gcc/match.pd b/gcc/match.pd
index 112deb3..7245ff4 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -1759,6 +1759,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
 (simplify
  (plus:c @3 (view_convert? (vec_cond @0 integer_each_onep@1 integer_zerop@2)))
  (if (VECTOR_TYPE_P (type)
+      && VECTOR_MODE_P (TYPE_MODE (TREE_TYPE (@0)))
       && TYPE_VECTOR_SUBPARTS (type) == TYPE_VECTOR_SUBPARTS (TREE_TYPE (@0))
       && (TYPE_MODE (TREE_TYPE (type))
           == TYPE_MODE (TREE_TYPE (TREE_TYPE (@0)))))
@@ -1768,6 +1769,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
 (simplify
  (minus @3 (view_convert? (vec_cond @0 integer_each_onep@1 integer_zerop@2)))
  (if (VECTOR_TYPE_P (type)
+      && VECTOR_MODE_P (TYPE_MODE (TREE_TYPE (@0)))
       && TYPE_VECTOR_SUBPARTS (type) == TYPE_VECTOR_SUBPARTS (TREE_TYPE (@0))
       && (TYPE_MODE (TREE_TYPE (type))
           == TYPE_MODE (TREE_TYPE (TREE_TYPE (@0)))))


More information about the Gcc-bugs mailing list