On Tue, Jan 09, 2024 at 04:35:22PM -0600, Peter Bergner wrote: > On 1/5/24 4:18 PM, Michael Meissner wrote: > > @@ -14504,13 +14504,17 @@ print_operand (FILE *file, rtx x, int code) > > print_operand (file, x, 0); > > return; > > > > + case 'S': > > case 'x': > > - /* X is a FPR or Altivec register used in a VSX context. */ > > + /* X is a FPR or Altivec register used in a VSX context. %x<n> > > prints > > + the VSX register number, %S<n> prints the 2nd register number for > > + vector pair, decimal 128-bit floating and IBM 128-bit binary floating > > + values. */ > > if (!REG_P (x) || !VSX_REGNO_P (REGNO (x))) > > - output_operand_lossage ("invalid %%x value"); > > + output_operand_lossage ("invalid %%%c value", (code == 'S' ? 'S' : > > 'x')); > > else > > { > > - int reg = REGNO (x); > > + int reg = REGNO (x) + (code == 'S' ? 1 : 0); > > int vsx_reg = (FP_REGNO_P (reg) > > ? reg - 32 > > : reg - FIRST_ALTIVEC_REGNO + 32); > > The above looks good to me. However: > > > > + : "=v" (*p) > > + : "v" (*q), "v" (*r)); > > These really should use "wa" rather than "v", since these are > VSX instructions... or did you use those to ensure you got > Altivec registers numbers assigned?
Yes in real code you would typically use "wa" instead of "v". I used them in the test to ensure that I was getting a register to show the problem. But I can imagine circumstances where you are doing extended asm with 2 or more instructions, one that uses an instruction that uses the VSX encoding (where you would use %S<n> and the other where you use the Altivec encoding where you would use %L<n>, and you would use the "v" constraint. > > +/* { dg-final { scan-assembler-times {\mxvadddp > > (3[2-9]|[45][0-9]|6[0-3]),(3[2-9]|[45][0-9]|6[0-3]),(3[2-9]|[45][0-9]|6[0-3])\M} > > 2 } } */ > > ...and this is really ugly and hard to read/understand. Can't we use > register variables to make it simpler? Something like the following > which tests having both FPR and Altivec reg numbers assigned? > > ... > void > test (__vector_pair *ptr) > { > register __vector_pair p asm ("vs10"); > register __vector_pair q asm ("vs42"); > register __vector_pair r asm ("vs44"); > q = ptr[1]; > r = ptr[2]; > __asm__ ("xvadddp %x0,%x1,%x2\n\txvadddp %S0,%S1,%S2" > : "=wa" (p) > : "wa" (q), "wa" (r)); > ptr[2] = p; > } > > /* { dg-final { scan-assembler-times {\mxvadddp 10,42,44\M} 1 } } */ > /* { dg-final { scan-assembler-times {\mxvadddp 11,43,45\M} 1 } } */ Yes that probably will work. -- Michael Meissner, IBM PO Box 98, Ayer, Massachusetts, USA, 01432 email: meiss...@linux.ibm.com