From: Robin Dapp Date: Mon, 8 Jul 2019 14:42:49 +0000 (+0000) Subject: S/390: Define shift_truncation_mask. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5fad9d33e1dacbd754473e441f5e305ba7d3ef6c;p=gcc.git S/390: Define shift_truncation_mask. Define s390_shift_truncation_mask to allow the optabs optimization sh = (64 - sh) -> sh = -sh for a rotation operation. gcc/ChangeLog: 2019-07-08 Robin Dapp * config/s390/s390.c (s390_shift_truncation_mask): Define. (TARGET_SHIFT_TRUNCATION_MASK): Define. gcc/testsuite/ChangeLog: 2019-07-08 Robin Dapp * gcc.target/s390/rotate-truncation-mask.c: New test. From-SVN: r273237 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c4f0503365a..b47aead64bd 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2019-07-08 Robin Dapp + + * config/s390/s390.c (s390_shift_truncation_mask): Define. + (TARGET_SHIFT_TRUNCATION_MASK): Define. + 2019-07-08 Robin Dapp * config/s390/constraints.md: Add new jsc constraint. diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c index 324d9d23210..75b0b5b4790 100644 --- a/gcc/config/s390/s390.c +++ b/gcc/config/s390/s390.c @@ -16412,7 +16412,13 @@ s390_sched_dependencies_evaluation (rtx_insn *head, rtx_insn *tail) add_dependence (r11_restore, r15_restore, REG_DEP_ANTI); } +/* Implement TARGET_SHIFT_TRUNCATION_MASK for integer shifts. */ +static unsigned HOST_WIDE_INT +s390_shift_truncation_mask (machine_mode mode) +{ + return mode == DImode || mode == SImode ? 63 : 0; +} /* Initialize GCC target structure. */ @@ -16709,6 +16715,8 @@ s390_sched_dependencies_evaluation (rtx_insn *head, rtx_insn *tail) #define TARGET_SCHED_DEPENDENCIES_EVALUATION_HOOK \ s390_sched_dependencies_evaluation +#undef TARGET_SHIFT_TRUNCATION_MASK +#define TARGET_SHIFT_TRUNCATION_MASK s390_shift_truncation_mask /* Use only short displacement, since long displacement is not available for the floating point instructions. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b1c6ea25ced..a7a67fb9fad 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2019-07-08 Robin Dapp + + * gcc.target/s390/rotate-truncation-mask.c: New test. + 2019-07-08 Robin Dapp * gcc.target/s390/combine-rotate-modulo.c: New test. diff --git a/gcc/testsuite/gcc.target/s390/rotate-truncation-mask.c b/gcc/testsuite/gcc.target/s390/rotate-truncation-mask.c new file mode 100644 index 00000000000..1cdd20913b9 --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/rotate-truncation-mask.c @@ -0,0 +1,11 @@ +/* Check that we do not use (64 - sh) for rotating. */ + +/* { dg-options "-O1 -m64" } */ + +/* { dg-final { scan-assembler "lcr\t%r.+,%r.+" } } */ +/* { dg-final { scan-assembler-not "lhi\t%r.+,64" } } */ +/* { dg-final { scan-assembler-not "sr\t%r.+,%r.+" } } */ +unsigned long rotr (unsigned long in, unsigned long sh) +{ + return (in >> sh) | (in << (64 - sh)); +}