This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] S/390: Optimize atomic_compare_exchange and atomic_compare builtins.
- From: Dominik Vogt <vogt at linux dot vnet dot ibm dot com>
- To: Ulrich Weigand <uweigand at de dot ibm dot com>
- Cc: gcc-patches at gcc dot gnu dot org, Andreas Krebbel <krebbel at linux dot vnet dot ibm dot com>, Ulrich Weigand <Ulrich dot Weigand at de dot ibm dot com>
- Date: Mon, 10 Apr 2017 10:13:01 +0100
- Subject: Re: [PATCH] S/390: Optimize atomic_compare_exchange and atomic_compare builtins.
- Authentication-results: sourceware.org; auth=none
- References: <20170407153715.GA5246@linux.vnet.ibm.com> <20170407172223.587ABD83154@oc3748833570.ibm.com>
- Reply-to: vogt at linux dot vnet dot ibm dot com
On Fri, Apr 07, 2017 at 07:22:23PM +0200, Ulrich Weigand wrote:
> Dominik Vogt wrote:
> > On Fri, Apr 07, 2017 at 04:34:44PM +0200, Ulrich Weigand wrote:
> > > > +; Peephole to combine a load-and-test from volatile memory which combine does
> > > > +; not do.
> > > > +(define_peephole2
> > > > + [(set (match_operand:GPR 0 "register_operand")
> > > > + (match_operand:GPR 2 "memory_operand"))
> > > > + (set (reg CC_REGNUM)
> > > > + (compare (match_dup 0) (match_operand:GPR 1 "const0_operand")))]
> > > > + "s390_match_ccmode(insn, CCSmode) && TARGET_EXTIMM
> > > > + && GENERAL_REG_P (operands[0])
> > > > + && satisfies_constraint_T (operands[2])"
> > > > + [(parallel
> > > > + [(set (reg:CCS CC_REGNUM)
> > > > + (compare:CCS (match_dup 2) (match_dup 1)))
> > > > + (set (match_dup 0) (match_dup 2))])])
> > >
> > > Still wondering why this is necessary.
> >
> > It's necessary vecause Combine refuses to match anything that
> > contains a volatile memory reference, using a global flag for
> > Recog.
>
> So is this specifically to match the pre-test load emitted here?
>
> + emit_move_insn (output, mem);
> + emit_insn (gen_rtx_SET (cc, gen_rtx_COMPARE (CCZmode, output, cmp)));
>
> If so, since you already know that this should always map to a
> LOAD AND TEST, could simply just emit the LT pattern here,
> instead of relying on combine to do it ...
Well, only if the value to compare to is constant zero (which is
what Glibc does). In all other cases this won't result in
load-and-test.
Ciao
Dominik ^_^ ^_^
--
Dominik Vogt
IBM Germany