aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2018-11-29 15:32:00 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2018-11-29 15:32:00 +0100
commitf06e47d7b644b4598a85f89eb76c13298e6e5d9f (patch)
tree154376b661fe1d100a310785cbfa7be99e6c267e /gcc/tree.c
parentb076fecbc240380b25bb25c65aae85c4b5ea9ce5 (diff)
downloadgcc-f06e47d7b644b4598a85f89eb76c13298e6e5d9f.zip
gcc-f06e47d7b644b4598a85f89eb76c13298e6e5d9f.tar.gz
gcc-f06e47d7b644b4598a85f89eb76c13298e6e5d9f.tar.bz2
re PR target/88152 (optimize SSE & AVX char compares with subsequent movmskb)
PR target/88152 * tree.h (build_uniform_cst, uniform_integer_cst_p): Declare. * tree.c (build_uniform_cst, uniform_integer_cst_p): New functions. * match.pd (define_predicates): Add uniform_integer_cst_p. (cmp @0 INTEGER_CST@1, cmp (convert?@2 @0) INTEGER_CST@1): Adjust so that it works also for vector comparisons with uniform constants with INTEGER_CST element. * g++.dg/tree-ssa/pr88152-1.C: New test. * g++.dg/tree-ssa/pr88152-2.C: New test. From-SVN: r266620
Diffstat (limited to 'gcc/tree.c')
-rw-r--r--gcc/tree.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index 1e19a0b..170ef13 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -1906,6 +1906,18 @@ build_vector_from_val (tree vectype, tree sc)
}
}
+/* If TYPE is not a vector type, just return SC, otherwise return
+ build_vector_from_val (TYPE, SC). */
+
+tree
+build_uniform_cst (tree type, tree sc)
+{
+ if (!VECTOR_TYPE_P (type))
+ return sc;
+
+ return build_vector_from_val (type, sc);
+}
+
/* Build a vector series of type TYPE in which element I has the value
BASE + I * STEP. The result is a constant if BASE and STEP are constant
and a VEC_SERIES_EXPR otherwise. */
@@ -11212,6 +11224,26 @@ uniform_vector_p (const_tree vec)
return NULL_TREE;
}
+/* If the argument is INTEGER_CST, return it. If the argument is vector
+ with all elements the same INTEGER_CST, return that INTEGER_CST. Otherwise
+ return NULL_TREE. */
+
+tree
+uniform_integer_cst_p (tree t)
+{
+ if (TREE_CODE (t) == INTEGER_CST)
+ return t;
+
+ if (VECTOR_TYPE_P (TREE_TYPE (t)))
+ {
+ t = uniform_vector_p (t);
+ if (t && TREE_CODE (t) == INTEGER_CST)
+ return t;
+ }
+
+ return NULL_TREE;
+}
+
/* Build an empty statement at location LOC. */
tree