aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorDominik Vogt <vogt@linux.vnet.ibm.com>2016-08-23 09:01:42 +0000
committerAndreas Krebbel <krebbel@gcc.gnu.org>2016-08-23 09:01:42 +0000
commitdeb9351fafe1032ced16f9608068f65930e06841 (patch)
treef500d077aa5fb6b297c28e717a86ed721f7cfbc5 /gcc
parent1fd9f058f37ba4c17cd34e961fe4879e7dd7e3bc (diff)
downloadgcc-deb9351fafe1032ced16f9608068f65930e06841.zip
gcc-deb9351fafe1032ced16f9608068f65930e06841.tar.gz
gcc-deb9351fafe1032ced16f9608068f65930e06841.tar.bz2
S/390: Add splitter for "and" with complement.
Split ~b & a to (b & a) ^ a. This is benefitial on z Systems since we otherwise need a big -1 constant to be loaded for the ~b. gcc/ChangeLog: 2016-08-23 Dominik Vogt <vogt@linux.vnet.ibm.com> * config/s390/s390.md ("*andc_split"): New splitter for and with complement. gcc/testsuite/ChangeLog: 2016-08-23 Dominik Vogt <vogt@linux.vnet.ibm.com> * gcc.target/s390/md/andc-splitter-1.c: New test case. * gcc.target/s390/md/andc-splitter-2.c: Likewise. From-SVN: r239685
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/config/s390/s390.md27
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.target/s390/md/andc-splitter-1.c61
-rw-r--r--gcc/testsuite/gcc.target/s390/md/andc-splitter-2.c61
5 files changed, 159 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 13b4ad5..8b1dc4b 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2016-08-23 Dominik Vogt <vogt@linux.vnet.ibm.com>
+
+ * config/s390/s390.md ("*andc_split"): New splitter for and with
+ complement.
+
2016-08-23 Richard Biener <rguenther@suse.de>
PR tree-optimization/27336
diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md
index a63cee9..30ddc14 100644
--- a/gcc/config/s390/s390.md
+++ b/gcc/config/s390/s390.md
@@ -7267,6 +7267,33 @@
(set_attr "z10prop" "z10_super_E1,z10_super,*")])
;
+; And with complement
+;
+; c = ~b & a = (b & a) ^ a
+
+(define_insn_and_split "*andc_split_<mode>"
+ [(set (match_operand:GPR 0 "nonimmediate_operand" "")
+ (and:GPR (not:GPR (match_operand:GPR 1 "nonimmediate_operand" ""))
+ (match_operand:GPR 2 "general_operand" "")))
+ (clobber (reg:CC CC_REGNUM))]
+ "! reload_completed && s390_logical_operator_ok_p (operands)"
+ "#"
+ "&& 1"
+ [
+ (parallel
+ [(set (match_dup 3) (and:GPR (match_dup 1) (match_dup 2)))
+ (clobber (reg:CC CC_REGNUM))])
+ (parallel
+ [(set (match_dup 0) (xor:GPR (match_dup 3) (match_dup 2)))
+ (clobber (reg:CC CC_REGNUM))])]
+{
+ if (reg_overlap_mentioned_p (operands[0], operands[2]))
+ operands[3] = gen_reg_rtx (<MODE>mode);
+ else
+ operands[3] = operands[0];
+})
+
+;
; Block and (NC) patterns.
;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 812c0c5..c02a4b8 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2016-08-23 Dominik Vogt <vogt@linux.vnet.ibm.com>
+
+ * gcc.target/s390/md/andc-splitter-1.c: New test case.
+ * gcc.target/s390/md/andc-splitter-2.c: Likewise.
+
2016-08-23 Richard Biener <rguenther@suse.de>
PR tree-optimization/27336
diff --git a/gcc/testsuite/gcc.target/s390/md/andc-splitter-1.c b/gcc/testsuite/gcc.target/s390/md/andc-splitter-1.c
new file mode 100644
index 0000000..ed78921
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/md/andc-splitter-1.c
@@ -0,0 +1,61 @@
+/* Machine description pattern tests. */
+
+/* { dg-do run { target { lp64 } } } */
+/* { dg-options "-mzarch -save-temps -dP" } */
+/* Skip test if -O0 is present on the command line:
+
+ { dg-skip-if "" { *-*-* } { "-O0" } { "" } }
+
+ Skip test if the -O option is missing from the command line
+ { dg-skip-if "" { *-*-* } { "*" } { "-O*" } }
+*/
+
+__attribute__ ((noinline))
+unsigned long andc_vv(unsigned long a, unsigned long b)
+{ return ~b & a; }
+/* { dg-final { scan-assembler ":15 .\* \{\\*anddi3\}" } } */
+/* { dg-final { scan-assembler ":15 .\* \{\\*xordi3\}" } } */
+
+__attribute__ ((noinline))
+unsigned long andc_pv(unsigned long *a, unsigned long b)
+{ return ~b & *a; }
+/* { dg-final { scan-assembler ":21 .\* \{\\*anddi3\}" } } */
+/* { dg-final { scan-assembler ":21 .\* \{\\*xordi3\}" } } */
+
+__attribute__ ((noinline))
+unsigned long andc_vp(unsigned long a, unsigned long *b)
+{ return ~*b & a; }
+/* { dg-final { scan-assembler ":27 .\* \{\\*anddi3\}" } } */
+/* { dg-final { scan-assembler ":27 .\* \{\\*xordi3\}" } } */
+
+__attribute__ ((noinline))
+unsigned long andc_pp(unsigned long *a, unsigned long *b)
+{ return ~*b & *a; }
+/* { dg-final { scan-assembler ":33 .\* \{\\*anddi3\}" } } */
+/* { dg-final { scan-assembler ":33 .\* \{\\*xordi3\}" } } */
+
+/* { dg-final { scan-assembler-times "\tngr\?k\?\t" 4 } } */
+/* { dg-final { scan-assembler-times "\txgr\?\t" 4 } } */
+
+int
+main (void)
+{
+ unsigned long a = 0xc00000000000000cllu;
+ unsigned long b = 0x500000000000000allu;
+ unsigned long e = 0x8000000000000004llu;
+ unsigned long c;
+
+ c = andc_vv (a, b);
+ if (c != e)
+ __builtin_abort ();
+ c = andc_pv (&a, b);
+ if (c != e)
+ __builtin_abort ();
+ c = andc_vp (a, &b);
+ if (c != e)
+ __builtin_abort ();
+ c = andc_pp (&a, &b);
+ if (c != e)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.target/s390/md/andc-splitter-2.c b/gcc/testsuite/gcc.target/s390/md/andc-splitter-2.c
new file mode 100644
index 0000000..d88da4d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/md/andc-splitter-2.c
@@ -0,0 +1,61 @@
+/* Machine description pattern tests. */
+
+/* { dg-do run } */
+/* { dg-options "-save-temps -dP" } */
+/* Skip test if -O0 is present on the command line:
+
+ { dg-skip-if "" { *-*-* } { "-O0" } { "" } }
+
+ Skip test if the -O option is missing from the command line
+ { dg-skip-if "" { *-*-* } { "*" } { "-O*" } }
+*/
+
+__attribute__ ((noinline))
+unsigned int andc_vv(unsigned int a, unsigned int b)
+{ return ~b & a; }
+/* { dg-final { scan-assembler ":15 .\* \{\\*andsi3_\(esa\|zarch\)\}" } } */
+/* { dg-final { scan-assembler ":15 .\* \{\\*xorsi3\}" } } */
+
+__attribute__ ((noinline))
+unsigned int andc_pv(unsigned int *a, unsigned int b)
+{ return ~b & *a; }
+/* { dg-final { scan-assembler ":21 .\* \{\\*andsi3_\(esa\|zarch\)\}" } } */
+/* { dg-final { scan-assembler ":21 .\* \{\\*xorsi3\}" } } */
+
+__attribute__ ((noinline))
+unsigned int andc_vp(unsigned int a, unsigned int *b)
+{ return ~*b & a; }
+/* { dg-final { scan-assembler ":27 .\* \{\\*andsi3_\(esa\|zarch\)\}" } } */
+/* { dg-final { scan-assembler ":27 .\* \{\\*xorsi3\}" } } */
+
+__attribute__ ((noinline))
+unsigned int andc_pp(unsigned int *a, unsigned int *b)
+{ return ~*b & *a; }
+/* { dg-final { scan-assembler ":33 .\* \{\\*andsi3_\(esa\|zarch\)\}" } } */
+/* { dg-final { scan-assembler ":33 .\* \{\\*xorsi3\}" } } */
+
+/* { dg-final { scan-assembler-times "\tnr\?k\?\t" 4 } } */
+/* { dg-final { scan-assembler-times "\txr\?k\?\t" 4 } } */
+
+int
+main (void)
+{
+ unsigned int a = 0xc000000cu;
+ unsigned int b = 0x5000000au;
+ unsigned int e = 0x80000004u;
+ unsigned int c;
+
+ c = andc_vv (a, b);
+ if (c != e)
+ __builtin_abort ();
+ c = andc_pv (&a, b);
+ if (c != e)
+ __builtin_abort ();
+ c = andc_vp (a, &b);
+ if (c != e)
+ __builtin_abort ();
+ c = andc_pp (&a, &b);
+ if (c != e)
+ __builtin_abort ();
+ return 0;
+}