Patch is rebased and merged with other changes according to comments.
Thanks!
-Zhenqiang
-Original Message-
From: gcc-patches-ow...@gcc.gnu.org [mailto:gcc-patches-
ow...@gcc.gnu.org] On Behalf Of Zhenqiang Chen
Sent: Tuesday, September 23, 2014 2:44 PM
To: gcc-patches@gcc.gnu.org
Subject: [Ping] [PATCH, 4/10] expand ccmp
Ping?
Patch is rebased and regenerated since [PATCH, 3/10] skip swapping
operands used in ccmp is discarded.
Please find the updated patch in attachment.
Bootstrap and no make check regression on X86-64.
Thanks!
-Zhenqiang
ChangeLog:
2014-09-23 Zhenqiang Chen zhenqiang.c...@linaro.org
* ccmp.c: New file.
* ccmp.h: New file.
* Makefile.in: Add ccmp.o
* expr.c: #include ccmp.h
(expand_expr_real_1): Try to expand ccmp.
-Original Message-
From: gcc-patches-ow...@gcc.gnu.org [mailto:gcc-patches-
ow...@gcc.gnu.org] On Behalf Of Zhenqiang Chen
Sent: Tuesday, July 01, 2014 4:01 PM
To: Richard Earnshaw
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH, 4/10] expand ccmp
On 25 June 2014 23:16, Richard Earnshaw rearn...@arm.com wrote:
On 23/06/14 07:59, Zhenqiang Chen wrote:
Hi,
This patch includes the main logic to expand ccmp instructions.
In the patch,
* ccmp_candidate_p is used to identify the CCMP candidate
* expand_ccmp_expr is the main entry, which calls
expand_ccmp_expr_1
to expand CCMP.
* expand_ccmp_expr_1 uses a recursive algorithm to expand CCMP.
It calls gen_ccmp_first and gen_ccmp_next to generate CCMP
instructions.
During expanding, we must make sure that no instruction can
clobber
the
CC reg except the compares. So clobber_cc_p and
check_clobber_cc
are
introduced to do the check.
* If the final result is not used in a COND_EXPR (checked by
function
used_in_cond_stmt_p), it calls cstorecc4 pattern to store the
CC to
a
general register.
Bootstrap and no make check regression on X86-64.
OK for trunk?
Thanks!
-Zhenqiang
ChangeLog:
2014-06-23 Zhenqiang Chen zhenqiang.c...@linaro.org
* ccmp.c (ccmp_candidate_p, used_in_cond_stmt_p,
check_clobber_cc,
clobber_cc_p, expand_ccmp_next, expand_ccmp_expr_1,
expand_ccmp_expr):
New functions to expand ccmp.
* ccmp.h (expand_ccmp_expr): New prototype.
* expr.c: #include ccmp.h
(expand_expr_real_1): Try to expand ccmp.
diff --git a/gcc/ccmp.c b/gcc/ccmp.c index 665c2a5..97b3910 100644
--- a/gcc/ccmp.c
+++ b/gcc/ccmp.c
@@ -47,6 +47,262 @@ along with GCC; see the file COPYING3. If not
see #include expmed.h
#include ccmp.h
+/* The following functions expand conditional compare (CCMP)
instructions.
+ Here is a short description about the over all algorithm:
+ * ccmp_candidate_p is used to identify the CCMP candidate
+
+ * expand_ccmp_expr is the main entry, which calls
expand_ccmp_expr_1
+ to expand CCMP.
+
+ * expand_ccmp_expr_1 uses a recursive algorithm to expand CCMP.
+ It calls two target hooks gen_ccmp_first and gen_ccmp_next
+ to
generate
+ CCMP instructions.
+- gen_ccmp_first expands the first compare in CCMP.
+- gen_ccmp_next expands the following compares.
+
+ During expanding, we must make sure that no instruction can
clobber
the
+ CC reg except the compares. So clobber_cc_p and
check_clobber_cc
are
+ introduced to do the check.
+
+ * If the final result is not used in a COND_EXPR (checked by
function
+ used_in_cond_stmt_p), it calls cstorecc4 pattern to store
+ the
CC to a
+ general register. */
+
+/* Check whether G is a potential conditional compare candidate.
+*/ static bool ccmp_candidate_p (gimple g) {
+ tree rhs = gimple_assign_rhs_to_tree (g);
+ tree lhs, op0, op1;
+ gimple gs0, gs1;
+ enum tree_code tcode, tcode0, tcode1;
+ tcode = TREE_CODE (rhs);
+
+ if (tcode != BIT_AND_EXPR tcode != BIT_IOR_EXPR)
+return false;
+
+ lhs = gimple_assign_lhs (g);
+ op0 = TREE_OPERAND (rhs, 0);
+ op1 = TREE_OPERAND (rhs, 1);
+
+ if ((TREE_CODE (op0) != SSA_NAME) || (TREE_CODE (op1) !=
SSA_NAME)
+ || !has_single_use (lhs))
+return false;
+
+ gs0 = get_gimple_for_ssa_name (op0);
+ gs1 = get_gimple_for_ssa_name (op1); if (!gs0 || !gs1 ||
+ !is_gimple_assign (gs0) || !is_gimple_assign (gs1)
+ /* g, gs0 and gs1 must be in the same basic block, since
+ current
stage
+is out-of-ssa. We can not guarantee the correctness when
forwording
+the gs0 and gs1 into g whithout DATAFLOW analysis. */
+ || gimple_bb (gs0) != gimple_bb (gs1)
+ || gimple_bb (gs0) != gimple_bb (g))
+return false;
+
+ if