This is the mail archive of the
mailing list for the GCC project.
RE: [PATCH 1/n] Add conditional compare support
- From: "Zhenqiang Chen" <zhenqiang dot chen at arm dot com>
- To: "'Hans-Peter Nilsson'" <hp at bitrange dot com>
- Cc: "Richard Earnshaw" <Richard dot Earnshaw at arm dot com>, "'Richard Biener'" <richard dot guenther at gmail dot com>, "GCC Patches" <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 30 Oct 2013 17:46:32 +0800
- Subject: RE: [PATCH 1/n] Add conditional compare support
- Authentication-results: sourceware.org; auth=none
- References: <000001ce9e58$6dadf230$4909d690$ at arm dot com> <CAFiYyc25hLxrAnsOXbfqYo=Rsw_MDopxb66bygfac-CEsffOEw at mail dot gmail dot com> <521C9406 dot 6050901 at arm dot com> <CAFiYyc0zrBBUvRF0Vmv5PyvypfK75QYuc3D9AMTE+Fkh3nCq4Q at mail dot gmail dot com> <000001ceb453$ceaea3c0$6c0beb40$ at arm dot com> <523AC006 dot 5030706 at arm dot com> <000101ceb829$31ec9040$95c5b0c0$ at arm dot com> <000101cecf0b$148b33a0$3da19ae0$ at arm dot com> <alpine dot BSF dot 2 dot 02 dot 1310282212590 dot 41279 at arjuna dot pair dot com>
> -----Original Message-----
> From: email@example.com [mailto:gcc-patches-
> firstname.lastname@example.org] On Behalf Of Hans-Peter Nilsson
> Sent: Tuesday, October 29, 2013 10:38 AM
> To: Zhenqiang Chen
> Cc: Richard Earnshaw; 'Richard Biener'; GCC Patches
> Subject: RE: [PATCH 1/n] Add conditional compare support
> On Tue, 22 Oct 2013, Zhenqiang Chen wrote:
> > ChangeLog:
> > 2013-10-22 Zhenqiang Chen <email@example.com>
> > * config/arm/arm.c (arm_fixed_condition_code_regs,
> > arm_select_dominance_ccmp_mode): New functions.
> > (arm_select_dominance_cc_mode_1): New function extracted from
> > arm_select_dominance_cc_mode.
> > (arm_select_dominance_cc_mode): Call
> > * config/arm/arm.md (ccmp, cbranchcc4, ccmp_and, ccmp_ior,
> > ccmp_ior_scc_scc, ccmp_ior_scc_scc_cmp, ccmp_and_scc_scc,
> > ccmp_and_scc_scc_cmp): New.
> > * config/arm/arm-protos.h (arm_select_dominance_ccmp_mode):
> > * expr.c (ccmp_candidate_p, used_in_cond_stmt_p,
> > expand_ccmp_expr_3, expand_ccmp_expr_1, expand_ccmp_expr):
> > (expand_expr_real_1): Handle ccmp.
> > * optabs.c: Include gimple.h.
> > (expand_ccmp_op): New.
> > (get_rtx_code): Handle BIT_AND_EXPR and BIT_IOR_EXPR.
> > * optabs.def (ccmp): New.
> > * optabs.h (expand_ccmp_op): New.
> > * doc/md.texi (ccmp): New index.
> One thing I don't see other people mentioning, is that this patch has just
> much code inside #ifdef HAVE_ccmp ... #endif.
> I couldn't actually find the part that *requires* that, i.e.
> code that does something like gen_ccmp (...) but maybe it's there.
In the arm.md, I define "(define_expand "ccmp" ...". It will be transferred
to function gen_ccmp (...). And it will define HAVE_ccmp.
In the updated patch, I add two backends hooks to generate conditional
> Where needed and where the conditioned code is more than a few lines,
> such code is preferably transformed into "if (0)":d code using constructs
> that at builtins.c:5354:
> #ifndef HAVE_atomic_clear
> # define HAVE_atomic_clear 0
> # define gen_atomic_clear(x,y) (gcc_unreachable (), NULL_RTX) #endif
> Right, this causes dead code, but for maintenance it's *much* better than
> when only a fraction of the code being compiled for other targets. (Also,
HAVE_ccmp is automatically generated when the target has ccmp instruction.
The code segments in #ifdef HAVE_ccmp ... #endif will *not* be compiled for
other targets, which do not define ccmp instruction.
> dead code may be eliminated by gcc.) Unfortunately the number of
> examples (as above) are few compared to the pages of #if
> HAVE_thisorthat'd code. :(
> (And IMHO that whole construct should be the default implementation and
> shouldn't have to be written manually in the first place. But that's
> for an invasive patch.)
After adding another two hooks, the code in middle-end is just a framework.
It fully depends on backend to generate the instruction.