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: "Ulrich Weigand" <uweigand at de dot ibm dot com>
- To: vogt at linux dot vnet dot ibm dot com
- Cc: gcc-patches at gcc dot gnu dot org, krebbel at linux dot vnet dot ibm dot com (Andreas Krebbel), Ulrich dot Weigand at de dot ibm dot com (Ulrich Weigand)
- Date: Fri, 7 Apr 2017 19:22:23 +0200 (CEST)
- Subject: Re: [PATCH] S/390: Optimize atomic_compare_exchange and atomic_compare builtins.
- Authentication-results: sourceware.org; auth=none
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 ...
Bye,
Ulrich
--
Dr. Ulrich Weigand
GNU/Linux compilers and toolchain
Ulrich.Weigand@de.ibm.com