From: Andreas Krebbel Date: Wed, 11 Jan 2023 10:17:42 +0000 (+0100) Subject: IBM zSystems: Use NAND instruction to implement bit not X-Git-Tag: basepoints/gcc-14~2106 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2ce074a7f858a1cd30ff68ec636dad9be218e04b;p=thirdparty%2Fgcc.git IBM zSystems: Use NAND instruction to implement bit not gcc/ChangeLog: * config/s390/s390.md (*not): New pattern. gcc/testsuite/ChangeLog: * gcc.target/s390/not.c: New test. --- diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md index 0e56fbad44d2..4828aa08be6f 100644 --- a/gcc/config/s390/s390.md +++ b/gcc/config/s390/s390.md @@ -8302,6 +8302,14 @@ "nrk\t%0,%1,%2" [(set_attr "op_type" "RRF")]) +; Use NAND for bit inversion +(define_insn "*not" + [(set (match_operand:GPR 0 "register_operand" "=d") + (not:GPR (match_operand:GPR 1 "register_operand" "d"))) + (clobber (reg:CC CC_REGNUM))] + "TARGET_Z15" + "nnrk\t%0,%1,%1" + [(set_attr "op_type" "RRF")]) ; ; Block inclusive or (OC) patterns. diff --git a/gcc/testsuite/gcc.target/s390/not.c b/gcc/testsuite/gcc.target/s390/not.c new file mode 100644 index 000000000000..dae95f7d8a06 --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/not.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -march=z15 -mzarch" } */ + +unsigned long +foo (unsigned long a) +{ + return ~a; +} + +/* { dg-final { scan-assembler-times "\tnngrk\t" 1 { target { lp64 } } } } */ +/* { dg-final { scan-assembler-times "\tnnrk\t" 1 { target { ! lp64 } } } } */