diff options
author | Richard Sandiford <richard.sandiford@linaro.org> | 2017-11-01 09:41:48 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2017-11-01 09:41:48 +0000 |
commit | 9b1de7e2e8e99eabf2b8d1ef74eb57fbd41bc730 (patch) | |
tree | a1caf2e58025d69aaf22ee8231dc382401c0e68a /gcc/selftest-rtl.c | |
parent | 59d06c050373919ed36a13b37103b6e069d8ebd3 (diff) | |
download | gcc-9b1de7e2e8e99eabf2b8d1ef74eb57fbd41bc730.zip gcc-9b1de7e2e8e99eabf2b8d1ef74eb57fbd41bc730.tar.gz gcc-9b1de7e2e8e99eabf2b8d1ef74eb57fbd41bc730.tar.bz2 |
Add more vec_duplicate simplifications
This patch adds a vec_duplicate_p helper that tests for constant
or non-constant vector duplicates. Together with the existing
const_vec_duplicate_p, this complements the gen_vec_duplicate
and gen_const_vec_duplicate added by a previous patch.
The patch uses the new routines to add more rtx simplifications
involving vector duplicates. These mirror simplifications that
we already do for CONST_VECTOR broadcasts and are needed for
variable-length SVE, which uses:
(const:M (vec_duplicate:M X))
to represent constant broadcasts instead. The simplifications do
trigger on the testsuite for variable duplicates too, and in each
case I saw the change was an improvement.
The best way of testing the new simplifications seemed to be
via selftests. The patch cribs part of David's patch here:
https://gcc.gnu.org/ml/gcc-patches/2016-07/msg00270.html .
2017-11-01 Richard Sandiford <richard.sandiford@linaro.org>
David Malcolm <dmalcolm@redhat.com>
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
gcc/
* rtl.h (vec_duplicate_p): New function.
* selftest-rtl.c (assert_rtx_eq_at): New function.
* selftest-rtl.h (ASSERT_RTX_EQ): New macro.
(assert_rtx_eq_at): Declare.
* selftest.h (selftest::simplify_rtx_c_tests): Declare.
* selftest-run-tests.c (selftest::run_tests): Call it.
* simplify-rtx.c: Include selftest.h and selftest-rtl.h.
(simplify_unary_operation_1): Recursively handle vector duplicates.
(simplify_binary_operation_1): Likewise. Handle VEC_SELECTs of
vector duplicates.
(simplify_subreg): Handle subregs of vector duplicates.
(make_test_reg, test_vector_ops_duplicate, test_vector_ops)
(selftest::simplify_rtx_c_tests): New functions.
Co-Authored-By: Alan Hayward <alan.hayward@arm.com>
Co-Authored-By: David Malcolm <dmalcolm@redhat.com>
Co-Authored-By: David Sherwood <david.sherwood@arm.com>
From-SVN: r254294
Diffstat (limited to 'gcc/selftest-rtl.c')
-rw-r--r-- | gcc/selftest-rtl.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/gcc/selftest-rtl.c b/gcc/selftest-rtl.c index bfb1ab7..7e74857 100644 --- a/gcc/selftest-rtl.c +++ b/gcc/selftest-rtl.c @@ -35,6 +35,29 @@ along with GCC; see the file COPYING3. If not see namespace selftest { +/* Compare rtx EXPECTED and ACTUAL using rtx_equal_p, calling + ::selftest::pass if they are equal, aborting if they are non-equal. + LOC is the effective location of the assertion, MSG describes it. */ + +void +assert_rtx_eq_at (const location &loc, const char *msg, + rtx expected, rtx actual) +{ + if (rtx_equal_p (expected, actual)) + ::selftest::pass (loc, msg); + else + { + fprintf (stderr, "%s:%i: %s: FAIL: %s\n", loc.m_file, loc.m_line, + loc.m_function, msg); + fprintf (stderr, " expected: "); + print_rtl (stderr, expected); + fprintf (stderr, "\n actual: "); + print_rtl (stderr, actual); + fprintf (stderr, "\n"); + abort (); + } +} + /* Compare rtx EXPECTED and ACTUAL by pointer equality, calling ::selftest::pass if they are equal, aborting if they are non-equal. LOC is the effective location of the assertion, MSG describes it. */ |