[4.8.[01]] PowerPC di-ti widening multiplication

2013-01-30 Thread Richard Henderson
For gcc 4.9, I intend to ensure that optabs.c can make automatic use of 
[us]mulmode_highpart.  There are plenty of targets that only implement 
_highpart but not the widening pattern.  But that's not something that 
would be appropriate at this stage in the 4.8 cycle.


Whether this patch is appropriate for 4.8.0 is someone else's call, but 
it's probably safe to queue it for 4.8.1.



r~


* config/rs6000/rs6000.md (smulditi3): New.
(umulditi3): New.

diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index a4af648..b3db681 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -6326,6 +6326,34 @@
   mulhdu %0,%1,%2
   [(set_attr type lmul)])
 
+(define_expand mulditi3
+  [(set (match_operand:TI 0 gpc_reg_operand)
+   (mult:TI (sign_extend:TI (match_operand:DI 1 gpc_reg_operand))
+(sign_extend:TI (match_operand:DI 2 gpc_reg_operand]
+  TARGET_POWERPC64
+{
+  rtx l = gen_reg_rtx (DImode), h = gen_reg_rtx (DImode);
+  emit_insn (gen_muldi3 (l, operands[1], operands[2]));
+  emit_insn (gen_smuldi3_highpart (h, operands[1], operands[2]));
+  emit_move_insn (gen_lowpart (DImode, operands[0]), l);
+  emit_move_insn (gen_highpart (DImode, operands[0]), h);
+  DONE;
+})
+
+(define_expand umulditi3
+  [(set (match_operand:TI 0 gpc_reg_operand)
+   (mult:TI (zero_extend:TI (match_operand:DI 1 gpc_reg_operand))
+(zero_extend:TI (match_operand:DI 2 gpc_reg_operand]
+  TARGET_POWERPC64
+{
+  rtx l = gen_reg_rtx (DImode), h = gen_reg_rtx (DImode);
+  emit_insn (gen_muldi3 (l, operands[1], operands[2]));
+  emit_insn (gen_umuldi3_highpart (h, operands[1], operands[2]));
+  emit_move_insn (gen_lowpart (DImode, operands[0]), l);
+  emit_move_insn (gen_highpart (DImode, operands[0]), h);
+  DONE;
+})
+
 (define_insn rotldi3
   [(set (match_operand:DI 0 gpc_reg_operand =r,r)
(rotate:DI (match_operand:DI 1 gpc_reg_operand r,r)


Re: [4.8.[01]] PowerPC di-ti widening multiplication

2013-01-30 Thread David Edelsohn
On Wed, Jan 30, 2013 at 1:17 PM, Richard Henderson r...@redhat.com wrote:
 For gcc 4.9, I intend to ensure that optabs.c can make automatic use of
 [us]mulmode_highpart.  There are plenty of targets that only implement
 _highpart but not the widening pattern.  But that's not something that would
 be appropriate at this stage in the 4.8 cycle.

 Whether this patch is appropriate for 4.8.0 is someone else's call, but it's
 probably safe to queue it for 4.8.1.

 * config/rs6000/rs6000.md (smulditi3): New.
 (umulditi3): New.

This patch is fine.  I don't have a problem with committing if for
4.8.0, unless the RMs object. In fact, I would rather add a new
instruction and deal with any fallout for 4.8.0 instead of 4.8.1.

Thanks, David


Re: [4.8.[01]] PowerPC di-ti widening multiplication

2013-01-30 Thread Jakub Jelinek
On Wed, Jan 30, 2013 at 04:27:57PM -0500, David Edelsohn wrote:
 On Wed, Jan 30, 2013 at 1:17 PM, Richard Henderson r...@redhat.com wrote:
  For gcc 4.9, I intend to ensure that optabs.c can make automatic use of
  [us]mulmode_highpart.  There are plenty of targets that only implement
  _highpart but not the widening pattern.  But that's not something that would
  be appropriate at this stage in the 4.8 cycle.
 
  Whether this patch is appropriate for 4.8.0 is someone else's call, but it's
  probably safe to queue it for 4.8.1.
 
  * config/rs6000/rs6000.md (smulditi3): New.
  (umulditi3): New.
 
 This patch is fine.  I don't have a problem with committing if for
 4.8.0, unless the RMs object. In fact, I would rather add a new
 instruction and deal with any fallout for 4.8.0 instead of 4.8.1.

I agree it is better to put it in now than after 4.8.0 is released.

Jakub