From a87d3f964df31d4fbceb822c6d293e85c117d992 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Wed, 14 Apr 2021 20:06:45 +0100 Subject: Check for matching CONST_VECTOR encodings [PR99929] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR99929 is one of those “how did we get away with this for so long” bugs: the equality routines weren't checking whether two variable-length CONST_VECTORs had the same encoding. This meant that: { 1, 0, 0, 0, 0, 0, ... } would appear to be equal to: { 1, 0, 1, 0, 1, 0, ... } since both are represented using the elements { 1, 0 }. gcc/ PR rtl-optimization/99929 * rtl.h (same_vector_encodings_p): New function. * cse.c (exp_equiv_p): Check that CONST_VECTORs have the same encoding. * cselib.c (rtx_equal_for_cselib_1): Likewise. * jump.c (rtx_renumbered_equal_p): Likewise. * lra-constraints.c (operands_match_p): Likewise. * reload.c (operands_match_p): Likewise. * rtl.c (rtx_equal_p_cb, rtx_equal_p): Likewise. gcc/testsuite/ * gcc.target/aarch64/sve/pr99929_1.c: New file. * gcc.target/aarch64/sve/pr99929_2.c: Likewise. --- gcc/jump.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gcc/jump.c') diff --git a/gcc/jump.c b/gcc/jump.c index 561dbb7..67b5c33 100644 --- a/gcc/jump.c +++ b/gcc/jump.c @@ -1777,6 +1777,11 @@ rtx_renumbered_equal_p (const_rtx x, const_rtx y) CASE_CONST_UNIQUE: return 0; + case CONST_VECTOR: + if (!same_vector_encodings_p (x, y)) + return false; + break; + case LABEL_REF: /* We can't assume nonlocal labels have their following insns yet. */ if (LABEL_REF_NONLOCAL_P (x) || LABEL_REF_NONLOCAL_P (y)) -- cgit v1.1