From 0d9e143c62c7a68474a39de40e5d6104074eee96 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 28 Oct 2016 09:12:52 +0200 Subject: [PATCH] re PR rtl-optimization/78132 (GCC produces invalid instruction (kmovd and kmovq) for KNL.) PR rtl-optimization/78132 * ree.c (combine_reaching_defs): Give up if copy_needed and !HARD_REGNO_MODE_OK (REGNO (src_reg), dst_mode). * gcc.target/i386/pr78132.c: New test. From-SVN: r241641 --- gcc/ChangeLog | 6 ++++++ gcc/ree.c | 5 +++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.target/i386/pr78132.c | 20 ++++++++++++++++++++ 4 files changed, 36 insertions(+) create mode 100644 gcc/testsuite/gcc.target/i386/pr78132.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 254d2624361..88805bd25c9 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-10-28 Jakub Jelinek + + PR rtl-optimization/78132 + * ree.c (combine_reaching_defs): Give up if copy_needed and + !HARD_REGNO_MODE_OK (REGNO (src_reg), dst_mode). + 2016-10-27 Eric Botcazou * config/sparc/sparc.md (<*vlop:code>3): Remove leading '*'. diff --git a/gcc/ree.c b/gcc/ree.c index 374988e792e..6bac17ef7fd 100644 --- a/gcc/ree.c +++ b/gcc/ree.c @@ -788,6 +788,11 @@ combine_reaching_defs (ext_cand *cand, const_rtx set_pat, ext_state *state) machine_mode dst_mode = GET_MODE (SET_DEST (PATTERN (cand->insn))); rtx src_reg = get_extended_src_reg (SET_SRC (PATTERN (cand->insn))); + /* Ensure we can use the src_reg in dst_mode (needed for + the (set (reg1) (reg2)) insn mentioned above). */ + if (!HARD_REGNO_MODE_OK (REGNO (src_reg), dst_mode)) + return false; + /* Ensure the number of hard registers of the copy match. */ if (HARD_REGNO_NREGS (REGNO (src_reg), dst_mode) != HARD_REGNO_NREGS (REGNO (src_reg), GET_MODE (src_reg))) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e3c8b63ea0a..08cc8bda7cb 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-10-28 Jakub Jelinek + + PR rtl-optimization/78132 + * gcc.target/i386/pr78132.c: New test. + 2016-10-27 Eric Botcazou * gcc.dg/vect/pr71264.c: XFAIL on SPARC. diff --git a/gcc/testsuite/gcc.target/i386/pr78132.c b/gcc/testsuite/gcc.target/i386/pr78132.c new file mode 100644 index 00000000000..e5a0e235a00 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr78132.c @@ -0,0 +1,20 @@ +/* PR rtl-optimization/78132 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -mavx512f -mno-avx512bw -mno-avx512dq -masm=att" } */ +/* { dg-final { scan-assembler-not "kmov\[dq]\t" } } */ + +unsigned short c; +char a, d, f, b; +short e; +long g; + +int +main () +{ + g = c; + f = c & e; + d = c & a | e; + if (a) + b = c; + return 0; +} -- 2.30.2