diff mbox series

[v2,rs6000] Disable TImode from Bool expanders [PR100694, PR93123]

Message ID 997b123b-f1f2-3330-6173-d983680dd8be@linux.ibm.com
State New
Headers show
Series [v2,rs6000] Disable TImode from Bool expanders [PR100694, PR93123] | expand

Commit Message

HAO CHEN GUI Feb. 21, 2022, 3:03 a.m. UTC
Hi,
  This patch disables TImode for Bool expanders. Thus TI register can be split
to two DI registers during expand.Potential optimizations can be implemented
after the split. The new test case illustrates it.

  Bootstrapped and tested on powerpc64-linux BE and LE with no regressions. Is
this okay for trunk? Any recommendations? Thanks a lot.

ChangeLog
2022-02-21 Haochen Gui <guihaoc@linux.ibm.com>

gcc/
	PR target/100694
	* config/rs6000/rs6000.md (and<mode>3): Disable TImode.
	(ior<mode>3): Likewise.
	(xor<mode>3): Likewise.
	(nor<mode>3): Likewise.
	(andc<mode>3): Likewise.
	(eqv<mode>3): Likewise.
	(nand<mode>3): Likewise.
	(orc<mode>3): Likewise.
	(one_cmpl<mode>2): Likewise.
	(*one_cmplti2): Enable TImode complement for combine and split.

gcc/testsuite/
	PR target/100694
	* gcc.target/powerpc/pr100694.c: New.
	* gcc.target/powerpc/pr92398.c: New.
	* gcc.target/powerpc/pr92398.h: Remove.
	* gcc.target/powerpc/pr92398.p9-.c: Remove.
	* gcc.target/powerpc/pr92398.p9+.c: Remove.


patch.diff
diff mbox series

Patch

diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index 6f74075f58d..1b1816d72ec 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -6976,21 +6976,21 @@  (define_expand "and<mode>3"
   [(set (match_operand:BOOL_128 0 "vlogical_operand")
 	(and:BOOL_128 (match_operand:BOOL_128 1 "vlogical_operand")
 		      (match_operand:BOOL_128 2 "vlogical_operand")))]
-  ""
+  "<MODE>mode != TImode"
   "")

 (define_expand "ior<mode>3"
   [(set (match_operand:BOOL_128 0 "vlogical_operand")
         (ior:BOOL_128 (match_operand:BOOL_128 1 "vlogical_operand")
 		      (match_operand:BOOL_128 2 "vlogical_operand")))]
-  ""
+  "<MODE>mode != TImode"
   "")

 (define_expand "xor<mode>3"
   [(set (match_operand:BOOL_128 0 "vlogical_operand")
         (xor:BOOL_128 (match_operand:BOOL_128 1 "vlogical_operand")
 		      (match_operand:BOOL_128 2 "vlogical_operand")))]
-  ""
+  "<MODE>mode != TImode"
   "")

 (define_expand "nor<mode>3"
@@ -6998,7 +6998,7 @@  (define_expand "nor<mode>3"
 	(and:BOOL_128
 	 (not:BOOL_128 (match_operand:BOOL_128 1 "vlogical_operand"))
 	 (not:BOOL_128 (match_operand:BOOL_128 2 "vlogical_operand"))))]
-  ""
+  "<MODE>mode != TImode"
   "")

 (define_expand "andc<mode>3"
@@ -7006,7 +7006,7 @@  (define_expand "andc<mode>3"
         (and:BOOL_128
 	 (not:BOOL_128 (match_operand:BOOL_128 2 "vlogical_operand"))
 	 (match_operand:BOOL_128 1 "vlogical_operand")))]
-  ""
+  "<MODE>mode != TImode"
   "")

 ;; Power8 vector logical instructions.
@@ -7015,7 +7015,7 @@  (define_expand "eqv<mode>3"
 	(not:BOOL_128
 	 (xor:BOOL_128 (match_operand:BOOL_128 1 "vlogical_operand")
 		       (match_operand:BOOL_128 2 "vlogical_operand"))))]
-  "<MODE>mode == TImode || <MODE>mode == PTImode || TARGET_P8_VECTOR"
+  "<MODE>mode != TImode && (<MODE>mode == PTImode || TARGET_P8_VECTOR)"
   "")

 ;; Rewrite nand into canonical form
@@ -7024,7 +7024,7 @@  (define_expand "nand<mode>3"
 	(ior:BOOL_128
 	 (not:BOOL_128 (match_operand:BOOL_128 1 "vlogical_operand"))
 	 (not:BOOL_128 (match_operand:BOOL_128 2 "vlogical_operand"))))]
-  "<MODE>mode == TImode || <MODE>mode == PTImode || TARGET_P8_VECTOR"
+  "<MODE>mode != TImode && (<MODE>mode == PTImode || TARGET_P8_VECTOR)"
   "")

 ;; The canonical form is to have the negated element first, so we need to
@@ -7034,7 +7034,7 @@  (define_expand "orc<mode>3"
 	(ior:BOOL_128
 	 (not:BOOL_128 (match_operand:BOOL_128 2 "vlogical_operand"))
 	 (match_operand:BOOL_128 1 "vlogical_operand")))]
-  "<MODE>mode == TImode || <MODE>mode == PTImode || TARGET_P8_VECTOR"
+  "<MODE>mode != TImode && (<MODE>mode == PTImode || TARGET_P8_VECTOR)"
   "")

 ;; 128-bit logical operations insns and split operations
@@ -7291,7 +7291,7 @@  (define_insn_and_split "one_cmpl<mode>2"
   [(set (match_operand:BOOL_128 0 "vlogical_operand" "=<BOOL_REGS_OUTPUT>")
 	(not:BOOL_128
 	  (match_operand:BOOL_128 1 "vlogical_operand" "<BOOL_REGS_UNARY>")))]
-  ""
+  "<MODE>mode != TImode"
 {
   if (TARGET_VSX && vsx_register_operand (operands[0], <MODE>mode))
     return "xxlnor %x0,%x1,%x1";
@@ -7321,6 +7321,39 @@  (define_insn_and_split "one_cmpl<mode>2"
 	 (const_string "8")
 	 (const_string "16"))))])

+(define_insn_and_split "*one_cmplti2"
+  [(set (match_operand:TI 0 "vlogical_operand" "=&r,r,r,wa,v")
+	(not:TI
+	  (match_operand:TI 1 "vlogical_operand" "r,0,0,wa,v")))]
+  ""
+{
+  if (TARGET_VSX && vsx_register_operand (operands[0], TImode))
+    return "xxlnor %x0,%x1,%x1";
+
+  if (TARGET_ALTIVEC && altivec_register_operand (operands[0], TImode))
+    return "vnor %0,%1,%1";
+
+  return "#";
+}
+  "reload_completed && int_reg_operand (operands[0], TImode)"
+  [(const_int 0)]
+{
+  rs6000_split_logical (operands, NOT, false, false, false);
+  DONE;
+}
+  [(set (attr "type")
+      (if_then_else
+	(match_test "vsx_register_operand (operands[0], TImode)")
+	(const_string "veclogical")
+	(const_string "integer")))
+   (set (attr "length")
+      (if_then_else
+	(match_test "vsx_register_operand (operands[0], TImode)")
+	(const_string "4")
+	(if_then_else
+	 (match_test "TARGET_POWERPC64")
+	 (const_string "8")
+	 (const_string "16"))))])
 
 ;; Now define ways of moving data around.

diff --git a/gcc/testsuite/gcc.target/powerpc/pr100694.c b/gcc/testsuite/gcc.target/powerpc/pr100694.c
new file mode 100644
index 00000000000..7b41d920140
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr100694.c
@@ -0,0 +1,15 @@ 
+/* { dg-do compile } */
+/* { dg-require-effective-target int128 } */
+/* { dg-options "-O2" } */
+/* { dg-final { scan-assembler-times {\mstd\M} 2 } } */
+/* { dg-final { scan-assembler-not {\mli\M} } } */
+/* { dg-final { scan-assembler-not {\mor\M} } } */
+
+/* It just needs two std.  */
+void foo (unsigned __int128* res, unsigned long long hi, unsigned long long lo)
+{
+   unsigned __int128 i = hi;
+   i <<= 64;
+   i |= lo;
+   *res = i;
+}
diff --git a/gcc/testsuite/gcc.target/powerpc/pr92398.c b/gcc/testsuite/gcc.target/powerpc/pr92398.c
new file mode 100644
index 00000000000..7d6201cc5bb
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr92398.c
@@ -0,0 +1,12 @@ 
+/* { dg-do compile } */
+/* { dg-require-effective-target int128 } */
+/* { dg-options "-O2" } */
+/* { dg-final { scan-assembler-times {\mnot\M} 2 } } */
+/* { dg-final { scan-assembler-times {\mstd\M} 2 } } */
+
+/* All platforms should generate the same instructions: not;not;std;std.  */
+void bar (__int128_t *dst, __int128_t src)
+{
+  *dst =  ~src;
+}
+
diff --git a/gcc/testsuite/gcc.target/powerpc/pr92398.h b/gcc/testsuite/gcc.target/powerpc/pr92398.h
deleted file mode 100644
index 5a4a8bcab80..00000000000
--- a/gcc/testsuite/gcc.target/powerpc/pr92398.h
+++ /dev/null
@@ -1,17 +0,0 @@ 
-/* This test code is included into pr92398.p9-.c and pr92398.p9+.c.
-   The two files have the tests for the number of instructions generated for
-   P9- versus P9+.
-
-   store generates difference instructions as below:
-   P9+: mtvsrdd;xxlnot;stxv.
-   P8/P7/P6 LE: not;not;std;std.
-   P8 BE: mtvsrd;mtvsrd;xxpermdi;xxlnor;stxvd2x.
-   P7/P6 BE: std;std;addi;lxvd2x;xxlnor;stxvd2x.
-   P9+ and P9- LE are expected, P6/P7/P8 BE are unexpected.  */
-
-void
-bar (__int128_t *dst, __int128_t src)
-{
-  *dst =  ~src;
-}
-
diff --git a/gcc/testsuite/gcc.target/powerpc/pr92398.p9+.c b/gcc/testsuite/gcc.target/powerpc/pr92398.p9+.c
deleted file mode 100644
index 72dd1d9a274..00000000000
--- a/gcc/testsuite/gcc.target/powerpc/pr92398.p9+.c
+++ /dev/null
@@ -1,12 +0,0 @@ 
-/* { dg-do compile { target { lp64 && has_arch_pwr9 } } } */
-/* { dg-require-effective-target powerpc_vsx_ok } */
-/* { dg-options "-O2 -mvsx" } */
-
-/* { dg-final { scan-assembler-times {\mmtvsrdd\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxxlnor\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mstxv\M} 1 } } */
-/* { dg-final { scan-assembler-not {\mld\M} } } */
-/* { dg-final { scan-assembler-not {\mnot\M} } } */
-
-/* Source code for the test in pr92398.h */
-#include "pr92398.h"
diff --git a/gcc/testsuite/gcc.target/powerpc/pr92398.p9-.c b/gcc/testsuite/gcc.target/powerpc/pr92398.p9-.c
deleted file mode 100644
index bd7fa98af51..00000000000
--- a/gcc/testsuite/gcc.target/powerpc/pr92398.p9-.c
+++ /dev/null
@@ -1,10 +0,0 @@ 
-/* { dg-do compile { target { lp64 && {! has_arch_pwr9} } } } */
-/* { dg-require-effective-target powerpc_vsx_ok } */
-/* { dg-options "-O2 -mvsx" } */
-
-/* { dg-final { scan-assembler-times {\mnot\M} 2 { xfail be } } } */
-/* { dg-final { scan-assembler-times {\mstd\M} 2 { xfail { { {! has_arch_pwr9} && has_arch_pwr8 } && be } } } } */
-
-/* Source code for the test in pr92398.h */
-#include "pr92398.h"
-