diff mbox

[rs6000] (3/3) Fix mulv4si3 and mulv8hi3 patterns for little endian

Message ID 1383611631.6275.335.camel@gnopaine
State New
Headers show

Commit Message

Bill Schmidt Nov. 5, 2013, 12:33 a.m. UTC
Hi,

Here's a revised version of this patch according to Richard's
suggestions.  It differs from the previous version only in the method
used to ensure vmulouh is generated; we now call the new
gen_altivec_vmulouh to accomplish this.

Bootstrapped and tested on powerpc64{,le}-unknown-linux-gnu with no
regressions.  Is this ok for trunk?

Thanks,
Bill


2013-11-04  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

	* config/rs6000/altivec.md (mulv4si3): Ensure we generate vmulouh
	for both big and little endian.
	(mulv8hi3): Swap input operands for merge high and merge low
	instructions for little endian.

Comments

David Edelsohn Nov. 6, 2013, 2:43 a.m. UTC | #1
On Mon, Nov 4, 2013 at 7:33 PM, Bill Schmidt
<wschmidt@linux.vnet.ibm.com> wrote:
> Hi,
>
> Here's a revised version of this patch according to Richard's
> suggestions.  It differs from the previous version only in the method
> used to ensure vmulouh is generated; we now call the new
> gen_altivec_vmulouh to accomplish this.
>
> Bootstrapped and tested on powerpc64{,le}-unknown-linux-gnu with no
> regressions.  Is this ok for trunk?
>
> Thanks,
> Bill
>
>
> 2013-11-04  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
>
>         * config/rs6000/altivec.md (mulv4si3): Ensure we generate vmulouh
>         for both big and little endian.
>         (mulv8hi3): Swap input operands for merge high and merge low
>         instructions for little endian.

Okay.

It's so annoying that sometimes vec mult odd for LE uses vmuleuh and
sometimes uses vmulouh depending on the context and the algorithm.
This unfortunately produces assembly code that is impossible to
follow.

Thanks, David
diff mbox

Patch

Index: gcc/config/rs6000/altivec.md
===================================================================
--- gcc/config/rs6000/altivec.md	(revision 204350)
+++ gcc/config/rs6000/altivec.md	(working copy)
@@ -651,7 +651,7 @@ 
    convert_move (small_swap, swap, 0);
  
    low_product = gen_reg_rtx (V4SImode);
-   emit_insn (gen_vec_widen_umult_odd_v8hi (low_product, one, two));
+   emit_insn (gen_altivec_vmulouh (low_product, one, two));
  
    high_product = gen_reg_rtx (V4SImode);
    emit_insn (gen_altivec_vmsumuhm (high_product, one, small_swap, zero));
@@ -678,13 +678,18 @@ 
    emit_insn (gen_vec_widen_smult_even_v8hi (even, operands[1], operands[2]));
    emit_insn (gen_vec_widen_smult_odd_v8hi (odd, operands[1], operands[2]));
 
-   emit_insn (gen_altivec_vmrghw (high, even, odd));
-   emit_insn (gen_altivec_vmrglw (low, even, odd));
-
    if (BYTES_BIG_ENDIAN)
-     emit_insn (gen_altivec_vpkuwum (operands[0], high, low));
+     {
+       emit_insn (gen_altivec_vmrghw (high, even, odd));
+       emit_insn (gen_altivec_vmrglw (low, even, odd));
+       emit_insn (gen_altivec_vpkuwum (operands[0], high, low));
+     }
    else
-     emit_insn (gen_altivec_vpkuwum (operands[0], low, high));
+     {
+       emit_insn (gen_altivec_vmrghw (high, odd, even));
+       emit_insn (gen_altivec_vmrglw (low, odd, even));
+       emit_insn (gen_altivec_vpkuwum (operands[0], low, high));
+     } 
 
    DONE;
 }")