[PATCH 1/3] Add power10 zero cycle moves for switches & indirect jumps

Michael Meissner meissner@linux.ibm.com
Mon Nov 22 21:12:19 GMT 2021


On Mon, Nov 22, 2021 at 10:36:13AM -0600, Bill Schmidt wrote:
> Hi Mike,
> 
> Thanks for this patch!
> > --- a/gcc/config/rs6000/rs6000.md
> > +++ b/gcc/config/rs6000/rs6000.md
> > @@ -12988,15 +12988,34 @@ (define_expand "indirect_jump"
> >      emit_jump_insn (gen_indirect_jump_nospec (Pmode, operands[0], ccreg));
> >      DONE;
> >    }
> > +  if (TARGET_P10_FUSION && TARGET_P10_FUSION_ZERO_CYCLE)
> > +    {
> > +      emit_jump_insn (gen_indirect_jump_zero_cycle (Pmode, operands[0]));
> > +      DONE;
> > +    }
> >  })
> >  
> >  (define_insn "*indirect_jump<mode>"
> >    [(set (pc)
> >  	(match_operand:P 0 "register_operand" "c,*l"))]
> > -  "rs6000_speculate_indirect_jumps"
> > +  "rs6000_speculate_indirect_jumps
> > +   && !(TARGET_P10_FUSION && TARGET_P10_FUSION_ZERO_CYCLE)"
> >    "b%T0"
> >    [(set_attr "type" "jmpreg")])
> >  
> > +(define_insn "@indirect_jump<mode>_zero_cycle"
> 
> I don't know why this is an "@" pattern, but honestly I don't
> know why @indirect_jump<mode>_nospec is an "@" pattern either.
> The documentation for such things is hard for me to understand,
> so I'm probably just missing something obvious, but I don't
> immediately see why we would need the @ here.

I didn't know about it either.  Basically the next insn used it:

(define_insn "@indirect_jump<mode>_nospec"
  [(set (pc) (match_operand:P 0 "register_operand" "c,*l"))
   (clobber (match_operand:CC 1 "cc_reg_operand" "=y,y"))]
  "!rs6000_speculate_indirect_jumps"
  "crset %E1\;beq%T0- %1\;b $"
  [(set_attr "type" "jmpreg")
   (set_attr "length" "12")])

This creates a function:

	gen_indirect_jump_nospec (machine_mode arg0, rtx x0, rtx x1)

where the mode of the P iterator is passed as argument.  I.e. you can do:

	rtx foo = gen_indirect_jump_nospec (Pmode, op0, op1);

instead of:

	rtx foo;
	if (Pmode == SImode)
	  foo = gen_indirect_jumpsi_nospec (op0, op1);
	else if (Pmode == DImode)
	  foo = gen_indirect_jumpdi_nospec (op0, op1);
	else
	  gcc_unreachable ();

> > +  [(set (pc)
> > +	(match_operand:P 0 "register_operand" "r,r,!cl"))
> > +   (clobber (match_scratch:P 1 "=c,*l,X"))]
> 
> Do we need the *l and X alternatives if we're only doing this for
> mtctr/bctr?

Probably not, but I recall back before the current allocator, that it would
cause crashes if we didn't have LR.  I could certainly eliminate the *l
alternative.

-- 
Michael Meissner, IBM
PO Box 98, Ayer, Massachusetts, USA, 01432
email: meissner@linux.ibm.com


More information about the Gcc-patches mailing list