This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 1/n] Add conditional compare framework in middle-end

On Mon, Feb 24, 2014 at 1:18 AM, Zhenqiang Chen
<> wrote:
> Hi,
> The patch ( 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.


> Is is OK for next stage1?
> Thanks!
> -Zhenqiang
> ChangeLog:
> 2014-02-24  Zhenqiang Chen  <>
>     * cfgexpand.c (expand_gimple_cond): Check ccmp support.
>     * doc/md.texi (ccmp): New index.
>     TARGET_GEN_CCMP_NEXT): New hooks.
>     TARGET_GEN_CCMP_NEXT): New hooks.
>     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
>     * 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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]