This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH 1/n] Add conditional compare framework in middle-end
- From: Andrew Pinski <pinskia at gmail dot com>
- To: Zhenqiang Chen <zhenqiang dot chen at linaro dot org>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, Richard Henderson <rth at redhat dot com>, Richard Earnshaw <rearnsha at arm dot com>
- Date: Sat, 14 Jun 2014 19:50:50 -0700
- Subject: Re: [PATCH 1/n] Add conditional compare framework in middle-end
- Authentication-results: sourceware.org; auth=none
- References: <CACgzC7BSeXOPrusUkz4mSSJ9+at5cfT68aqsKRjkjMzL+Wji9Q at mail dot gmail dot com>
On Mon, Feb 24, 2014 at 1:18 AM, Zhenqiang Chen
<zhenqiang.chen@linaro.org> wrote:
> Hi,
>
> The patch (http://gcc.gnu.org/ml/gcc-patches/2014-11/msg03622.html) is
> re-based (the arm port change is stripped as a separate patch), which
> includes only the middle-end changes. The basic logic for the patch
> is:
>
> 1) Identify conditional compare candidates when expanding one GIMPLE_COND.
> 2) For a candidate, it uses two target hooks to generate the expected codes:
> - gen_ccmp_first expands the first compare in CCMP.
> - gen_ccmp_next expands the following compares.
>
> Another hook select_ccmp_cmp_order is called to determine which compare
> is done first since not all combination of compares are legal in some
> target like ARM. We might get more chance when swapping the compares.
> For AARCH64 and IA64, we do not need such check.
>
> During expanding, we must make sure that no instruction can clobber the
> CC reg except the compares.
>
> If the final result is not used in a COND_EXPR, it calls cstorecc4 pattern
> to store the CC to a general register.
>
> Bootstrap and no make check regression on X86-64.
I was testing this patch set out on AARCH64 with an addition patch to
define cstorecc4 and found an issue:
+ rtx target = gen_reg_rtx (word_mode);
+ tmp = emit_cstore (target, icode, NE, CCmode, CCmode,
+ 0, tmp, const0_rtx, 1, word_mode);
+ if (tmp)
+ return tmp;
The wrong mode is being used in the above code.
The testcase is:
_Bool f(int a, int b)
{
return a != 0 && b != 0;
}
---- CUT ----
I am working on the patch to fix this issue.
Thanks,
Andrew
>
> Is is OK for next stage1?
>
> Thanks!
> -Zhenqiang
>
> ChangeLog:
> 2014-02-24 Zhenqiang Chen <zhenqiang.chen@linaro.org>
>
> * cfgexpand.c (expand_gimple_cond): Check ccmp support.
> * doc/md.texi (ccmp): New index.
> * doc/tm.texi (TARGET_SELECT_CCMP_CMP_ORDER, TARGET_GEN_CCMP_FIRST,
> TARGET_GEN_CCMP_NEXT): New hooks.
> * doc/tm.texi (TARGET_SELECT_CCMP_CMP_ORDER, TARGET_GEN_CCMP_FIRST,
> TARGET_GEN_CCMP_NEXT): New hooks.
> * doc/tm.texi.in (TARGET_SELECT_CCMP_CMP_ORDER, TARGET_GEN_CCMP_FIRST,
> TARGET_GEN_CCMP_NEXT): New hooks.
> * expmed.c (emit_cstore): Make it global.
> * expr.c: Include tree-phinodes.h and ssa-iterators.h.
> (ccmp_candidate_p, used_in_cond_stmt_p, check_clobber_cc, clobber_cc_p,
> gen_ccmp_next, expand_ccmp_expr_1, expand_ccmp_expr): New functions.
> (expand_expr_real_1): Handle conditional compare.
> * optabs.c (get_rtx_code): Make it global and handle BIT_AND_EXPR and
> BIT_IOR_EXPR.
> * optabs.h (get_rtx_code, emit_cstore): New prototypes.
> * recog.c (ccmp_insn_p): New function.
> (simplify_while_replacing): Do not swap ccmp insn.
> * target.def (select_ccmp_cmp_order, gen_ccmp_first, gen_ccmp_next):
> Define hooks.
> * targhooks.c (default_select_ccmp_cmp_order): New function.
> * targhooks.h (default_select_ccmp_cmp_order): New prototypes.