From 6b7d84532342ed038a07d850ddacf7a86106a998 Mon Sep 17 00:00:00 2001 From: Uros Bizjak Date: Sun, 4 Dec 2016 15:38:05 +0100 Subject: [PATCH] re PR target/70322 (STV doesn't optimize andn) PR target/70322 * config/i386/i386.c (dimode_scalar_to_vector_candidate_p): Handle NEG. (dimode_scalar_chain::compute_convert_gain): Ditto. (dimode_scalar_chain::convert_insn): Ditto. testsuite/ChangeLog: PR target/70322 * gcc.target/i386/pr70322-4.c: New test. From-SVN: r243228 --- gcc/ChangeLog | 9 ++++++++- gcc/config/i386/i386.c | 15 +++++++++++++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.target/i386/pr70322-4.c | 13 +++++++++++++ 4 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr70322-4.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 496c691afdc..e888c036fe1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,10 +1,17 @@ +2016-12-04 Uros Bizjak + + PR target/70322 + * config/i386/i386.c (dimode_scalar_to_vector_candidate_p): Handle NEG. + (dimode_scalar_chain::compute_convert_gain): Ditto. + (dimode_scalar_chain::convert_insn): Ditto. + 2016-12-03 Eric Botcazou * lra-constraints.c (emit_spill_move): Use gen_lowpart_SUBREG in all cases to build a lowpart SUBREG. 2016-12-03 Eric Botcazou - David S. Miller + David S. Miller * config/sparc/constraints.md (U): Adjust comment. * config/sparc/sparc.md (lra): New attribute. diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 0bee09b2c60..41717da822a 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -2826,6 +2826,7 @@ dimode_scalar_to_vector_candidate_p (rtx_insn *insn) return false; break; + case NEG: case NOT: break; @@ -2851,7 +2852,8 @@ dimode_scalar_to_vector_candidate_p (rtx_insn *insn) if ((GET_MODE (XEXP (src, 0)) != DImode && !CONST_INT_P (XEXP (src, 0))) - || (GET_CODE (src) != NOT + || (GET_CODE (src) != NEG + && GET_CODE (src) != NOT && GET_MODE (XEXP (src, 1)) != DImode && !CONST_INT_P (XEXP (src, 1)))) return false; @@ -3419,7 +3421,8 @@ dimode_scalar_chain::compute_convert_gain () if (CONST_INT_P (XEXP (src, 1))) gain -= vector_const_cost (XEXP (src, 1)); } - else if (GET_CODE (src) == NOT) + else if (GET_CODE (src) == NEG + || GET_CODE (src) == NOT) gain += ix86_cost->add - COSTS_N_INSNS (1); else if (GET_CODE (src) == COMPARE) { @@ -3776,6 +3779,14 @@ dimode_scalar_chain::convert_insn (rtx_insn *insn) PUT_MODE (src, V2DImode); break; + case NEG: + src = XEXP (src, 0); + convert_op (&src, insn); + subreg = gen_reg_rtx (V2DImode); + emit_insn_before (gen_move_insn (subreg, CONST0_RTX (V2DImode)), insn); + src = gen_rtx_MINUS (V2DImode, subreg, src); + break; + case NOT: src = XEXP (src, 0); convert_op (&src, insn); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 84fc6fa83bc..a323678ff7f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-12-04 Uros Bizjak + + PR target/70322 + * gcc.target/i386/pr70322-4.c: New test. + 2016-12-03 Janus Weil PR fortran/43207 diff --git a/gcc/testsuite/gcc.target/i386/pr70322-4.c b/gcc/testsuite/gcc.target/i386/pr70322-4.c new file mode 100644 index 00000000000..8a02b9b031f --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr70322-4.c @@ -0,0 +1,13 @@ +/* PR target/70322 */ +/* { dg-do compile { target ia32 } } */ +/* { dg-options "-O2 -msse2 -mstv" } */ +/* { dg-final { scan-assembler "psub" } } */ +/* { dg-final { scan-assembler "por" } } */ + +extern long long z; + +void +foo (long long x, long long y) +{ + z = -x | y; +} -- 2.30.2