public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 1/2] rs6000: Implement cstore for signed Pmode register compares
@ 2015-12-04 14:34 Segher Boessenkool
  2015-12-04 14:34 ` [PATCH 2/2] rs6000: Clean up the cstore code a bit Segher Boessenkool
  2015-12-04 14:55 ` [PATCH 1/2] rs6000: Implement cstore for signed Pmode register compares David Edelsohn
  0 siblings, 2 replies; 4+ messages in thread
From: Segher Boessenkool @ 2015-12-04 14:34 UTC (permalink / raw)
  To: gcc-patches; +Cc: dje.gcc, Segher Boessenkool

This implements cstore for the last case we do not yet handle, using
the superopt algo from the venerable CWG.  The only integer cases we
do still not handle after this are for -m32 -mpowerpc64.  Those case
now generate a branch sequence, which is better than what we had
before.

Tested on powerpc64-linux; okay for mainline?


Segher


2015-12-04  Segher Boessenkool  <segher&kernel.crashing.org>

	* (cstore<mode>4_signed): New expander.
	(cstore<mode>4): Call it.  FAIL instead of calling rs6000_emit_sCOND.

---
 gcc/config/rs6000/rs6000.md | 50 +++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 48 insertions(+), 2 deletions(-)

diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index 26b0962..98abdb2 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -10525,6 +10525,47 @@ (define_expand "cbranch<mode>4"
   DONE;
 }")
 
+(define_expand "cstore<mode>4_signed"
+  [(use (match_operator 1 "signed_comparison_operator"
+         [(match_operand:P 2 "gpc_reg_operand")
+          (match_operand:P 3 "gpc_reg_operand")]))
+   (clobber (match_operand:P 0 "gpc_reg_operand"))]
+  ""
+{
+  enum rtx_code cond_code = GET_CODE (operands[1]);
+
+  rtx op0 = operands[0];
+  rtx op1 = operands[2];
+  rtx op2 = operands[3];
+
+  if (cond_code == GE || cond_code == LT)
+    {
+      cond_code = swap_condition (cond_code);
+      std::swap (op1, op2);
+    }
+
+  rtx tmp1 = gen_reg_rtx (<MODE>mode);
+  rtx tmp2 = gen_reg_rtx (<MODE>mode);
+  rtx tmp3 = gen_reg_rtx (<MODE>mode);
+
+  int sh = GET_MODE_BITSIZE (<MODE>mode) - 1;
+  emit_insn (gen_lshr<mode>3 (tmp1, op1, GEN_INT (sh)));
+  emit_insn (gen_ashr<mode>3 (tmp2, op2, GEN_INT (sh)));
+
+  emit_insn (gen_subf<mode>3_carry (tmp3, op1, op2));
+
+  if (cond_code == LE)
+    emit_insn (gen_add<mode>3_carry_in (op0, tmp1, tmp2));
+  else
+    {
+      rtx tmp4 = gen_reg_rtx (<MODE>mode);
+      emit_insn (gen_add<mode>3_carry_in (tmp4, tmp1, tmp2));
+      emit_insn (gen_xor<mode>3 (op0, tmp4, const1_rtx));
+    }
+
+  DONE;
+})
+
 (define_expand "cstore<mode>4_unsigned"
   [(use (match_operator 1 "unsigned_comparison_operator"
          [(match_operand:P 2 "gpc_reg_operand" "")
@@ -10751,9 +10792,14 @@ (define_expand "cstore<mode>4"
     emit_insn (gen_cstore<mode>4_unsigned_imm (operands[0], operands[1],
 					       operands[2], operands[3]));
 
-  /* Everything else, use the mfcr brute force.  */
+  /* We also do not want to use mfcr for signed comparisons.  */
+  else if (<MODE>mode == Pmode
+	   && signed_comparison_operator (operands[1], VOIDmode))
+    emit_insn (gen_cstore<mode>4_signed (operands[0], operands[1],
+					 operands[2], operands[3]));
+
   else
-    rs6000_emit_sCOND (<MODE>mode, operands);
+    FAIL;
 
   DONE;
 })
-- 
1.9.3

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/2] rs6000: Clean up the cstore code a bit
  2015-12-04 14:34 [PATCH 1/2] rs6000: Implement cstore for signed Pmode register compares Segher Boessenkool
@ 2015-12-04 14:34 ` Segher Boessenkool
  2015-12-04 14:46   ` David Edelsohn
  2015-12-04 14:55 ` [PATCH 1/2] rs6000: Implement cstore for signed Pmode register compares David Edelsohn
  1 sibling, 1 reply; 4+ messages in thread
From: Segher Boessenkool @ 2015-12-04 14:34 UTC (permalink / raw)
  To: gcc-patches; +Cc: dje.gcc, Segher Boessenkool

"register_operand" was a bit confusing.  Also some other minor cleanups.

Tested on powerpc64-linux; okay for mainline?


Segher


2015-12-04  Segher Boessenkool  <segher&kernel.crashing.org>

	* (cstore<mode>4_unsigned): Use gpc_reg_operand instead of
	register_operand.  Remove empty constraints.  Use std::swap.
	(cstore_si_as_di, cstore<mode>4_signed_imm,
	cstore<mode>4_unsigned_imm, cstore<mode>4 for GPR): Use
	gpc_reg_operand instead of register_operand.
	(cstore<mode>4 for FP): Use gpc_reg_operand instead of
	register_operand.  Remove empty constraints.

---
 gcc/config/rs6000/rs6000.md | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index 98abdb2..80f4161 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -10568,9 +10568,9 @@ (define_expand "cstore<mode>4_signed"
 
 (define_expand "cstore<mode>4_unsigned"
   [(use (match_operator 1 "unsigned_comparison_operator"
-         [(match_operand:P 2 "gpc_reg_operand" "")
-          (match_operand:P 3 "reg_or_short_operand" "")]))
-   (clobber (match_operand:P 0 "register_operand"))]
+         [(match_operand:P 2 "gpc_reg_operand")
+          (match_operand:P 3 "reg_or_short_operand")]))
+   (clobber (match_operand:P 0 "gpc_reg_operand"))]
   ""
 {
   enum rtx_code cond_code = GET_CODE (operands[1]);
@@ -10582,8 +10582,7 @@ (define_expand "cstore<mode>4_unsigned"
   if (cond_code == GEU || cond_code == LTU)
     {
       cond_code = swap_condition (cond_code);
-      op1 = operands[3];
-      op2 = operands[2];
+      std::swap (op1, op2);
     }
 
   if (!gpc_reg_operand (op1, <MODE>mode))
@@ -10609,7 +10608,7 @@ (define_expand "cstore_si_as_di"
   [(use (match_operator 1 "unsigned_comparison_operator"
          [(match_operand:SI 2 "gpc_reg_operand")
           (match_operand:SI 3 "reg_or_short_operand")]))
-   (clobber (match_operand:SI 0 "register_operand"))]
+   (clobber (match_operand:SI 0 "gpc_reg_operand"))]
   ""
 {
   int uns_flag = unsigned_comparison_operator (operands[1], VOIDmode) ? 1 : 0;
@@ -10654,7 +10653,7 @@ (define_expand "cstore<mode>4_signed_imm"
   [(use (match_operator 1 "signed_comparison_operator"
          [(match_operand:GPR 2 "gpc_reg_operand")
           (match_operand:GPR 3 "immediate_operand")]))
-   (clobber (match_operand:GPR 0 "register_operand"))]
+   (clobber (match_operand:GPR 0 "gpc_reg_operand"))]
   ""
 {
   bool invert = false;
@@ -10699,7 +10698,7 @@ (define_expand "cstore<mode>4_unsigned_imm"
   [(use (match_operator 1 "unsigned_comparison_operator"
          [(match_operand:GPR 2 "gpc_reg_operand")
           (match_operand:GPR 3 "immediate_operand")]))
-   (clobber (match_operand:GPR 0 "register_operand"))]
+   (clobber (match_operand:GPR 0 "gpc_reg_operand"))]
   ""
 {
   bool invert = false;
@@ -10746,7 +10745,7 @@ (define_expand "cstore<mode>4"
   [(use (match_operator 1 "rs6000_cbranch_operator"
          [(match_operand:GPR 2 "gpc_reg_operand")
           (match_operand:GPR 3 "reg_or_short_operand")]))
-   (clobber (match_operand:GPR 0 "register_operand"))]
+   (clobber (match_operand:GPR 0 "gpc_reg_operand"))]
   ""
 {
   /* Use ISEL if the user asked for it.  */
@@ -10806,9 +10805,9 @@ (define_expand "cstore<mode>4"
 
 (define_expand "cstore<mode>4"
   [(use (match_operator 1 "rs6000_cbranch_operator"
-         [(match_operand:FP 2 "gpc_reg_operand" "")
-          (match_operand:FP 3 "gpc_reg_operand" "")]))
-   (clobber (match_operand:SI 0 "register_operand"))]
+         [(match_operand:FP 2 "gpc_reg_operand")
+          (match_operand:FP 3 "gpc_reg_operand")]))
+   (clobber (match_operand:SI 0 "gpc_reg_operand"))]
   ""
 {
   rs6000_emit_sCOND (<MODE>mode, operands);
-- 
1.9.3

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] rs6000: Clean up the cstore code a bit
  2015-12-04 14:34 ` [PATCH 2/2] rs6000: Clean up the cstore code a bit Segher Boessenkool
@ 2015-12-04 14:46   ` David Edelsohn
  0 siblings, 0 replies; 4+ messages in thread
From: David Edelsohn @ 2015-12-04 14:46 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: GCC Patches

On Fri, Dec 4, 2015 at 9:34 AM, Segher Boessenkool
<segher@kernel.crashing.org> wrote:
> "register_operand" was a bit confusing.  Also some other minor cleanups.
>
> Tested on powerpc64-linux; okay for mainline?
>
>
> Segher
>
>
> 2015-12-04  Segher Boessenkool  <segher&kernel.crashing.org>
>
>         * (cstore<mode>4_unsigned): Use gpc_reg_operand instead of
>         register_operand.  Remove empty constraints.  Use std::swap.
>         (cstore_si_as_di, cstore<mode>4_signed_imm,
>         cstore<mode>4_unsigned_imm, cstore<mode>4 for GPR): Use
>         gpc_reg_operand instead of register_operand.
>         (cstore<mode>4 for FP): Use gpc_reg_operand instead of
>         register_operand.  Remove empty constraints.

Okay.

Thanks, David

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] rs6000: Implement cstore for signed Pmode register compares
  2015-12-04 14:34 [PATCH 1/2] rs6000: Implement cstore for signed Pmode register compares Segher Boessenkool
  2015-12-04 14:34 ` [PATCH 2/2] rs6000: Clean up the cstore code a bit Segher Boessenkool
@ 2015-12-04 14:55 ` David Edelsohn
  1 sibling, 0 replies; 4+ messages in thread
From: David Edelsohn @ 2015-12-04 14:55 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: GCC Patches

On Fri, Dec 4, 2015 at 9:34 AM, Segher Boessenkool
<segher@kernel.crashing.org> wrote:
> This implements cstore for the last case we do not yet handle, using
> the superopt algo from the venerable CWG.  The only integer cases we
> do still not handle after this are for -m32 -mpowerpc64.  Those case
> now generate a branch sequence, which is better than what we had
> before.
>
> Tested on powerpc64-linux; okay for mainline?
>
>
> Segher
>
>
> 2015-12-04  Segher Boessenkool  <segher&kernel.crashing.org>
>
>         * (cstore<mode>4_signed): New expander.
>         (cstore<mode>4): Call it.  FAIL instead of calling rs6000_emit_sCOND.

The new expander is okay as well as calling it.

Please do not remove the fallback to sCOND without performance testing.

Thanks, David

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-12-04 14:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-04 14:34 [PATCH 1/2] rs6000: Implement cstore for signed Pmode register compares Segher Boessenkool
2015-12-04 14:34 ` [PATCH 2/2] rs6000: Clean up the cstore code a bit Segher Boessenkool
2015-12-04 14:46   ` David Edelsohn
2015-12-04 14:55 ` [PATCH 1/2] rs6000: Implement cstore for signed Pmode register compares David Edelsohn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).