> -----Original Message----- > From: gcc-patches-ow...@gcc.gnu.org [mailto:gcc-patches- > ow...@gcc.gnu.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 <zhenqiang.c...@linaro.org> > > > > * config/arm/arm.c (arm_fixed_condition_code_regs, > arm_ccmode_to_code, > > 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 > arm_select_dominance_cc_mode_1. > > * 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): > New. > > * expr.c (ccmp_candidate_p, used_in_cond_stmt_p, > expand_ccmp_expr_2, > > expand_ccmp_expr_3, expand_ccmp_expr_1, expand_ccmp_expr): > New. > > (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 too > 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 compare instruction. > 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 like > 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, the 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 material > 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. Thanks! -Zhenqiang