Message ID | alpine.DEB.2.20.2310160141130.5892@tpp.orcam.me.uk |
---|---|
State | New |
Headers | show |
Series | [RFA] PR target/111815: VAX: Only accept the index scaler as the RHS operand to ASHIFT | expand |
On Mon, 16 Oct 2023, Maciej W. Rozycki wrote: > The testcase is generic enough I thought it wouldn't hurt to place it in > a generic part of the testsuite, where it has been verified to pass with > the `powerpc64le-linux-gnu', `riscv64-linux-gnu', and `vax-netbsdelf' > targets. I'm fine to move it to the VAX part of the testsuite though if > there's disagreement as to my choice. Otherwise OK to apply for this > part? Ping for: <https://gcc.gnu.org/pipermail/gcc-patches/2023-October/633112.html>. Maciej
On Mon, 16 Oct 2023, Maciej W. Rozycki wrote: > The testcase is generic enough I thought it wouldn't hurt to place it in > a generic part of the testsuite, where it has been verified to pass with > the `powerpc64le-linux-gnu', `riscv64-linux-gnu', and `vax-netbsdelf' > targets. I'm fine to move it to the VAX part of the testsuite though if > there's disagreement as to my choice. Otherwise OK to apply for this > part? Ping for: <https://gcc.gnu.org/pipermail/gcc-patches/2023-October/633112.html>. Maciej
On 11/13/23 13:22, Maciej W. Rozycki wrote: > On Mon, 16 Oct 2023, Maciej W. Rozycki wrote: > >> The testcase is generic enough I thought it wouldn't hurt to place it in >> a generic part of the testsuite, where it has been verified to pass with >> the `powerpc64le-linux-gnu', `riscv64-linux-gnu', and `vax-netbsdelf' >> targets. I'm fine to move it to the VAX part of the testsuite though if >> there's disagreement as to my choice. Otherwise OK to apply for this >> part? > > Ping for: > <https://gcc.gnu.org/pipermail/gcc-patches/2023-October/633112.html>. OK. I'm fully supportive of generic tests :-) Jeff
On Mon, 13 Nov 2023, Jeff Law wrote: > > > The testcase is generic enough I thought it wouldn't hurt to place it in > > > a generic part of the testsuite, where it has been verified to pass with > > > the `powerpc64le-linux-gnu', `riscv64-linux-gnu', and `vax-netbsdelf' > > > targets. I'm fine to move it to the VAX part of the testsuite though if > > > there's disagreement as to my choice. Otherwise OK to apply for this > > > part? > > > > Ping for: > > <https://gcc.gnu.org/pipermail/gcc-patches/2023-October/633112.html>. > OK. I'm fully supportive of generic tests :-) Thank you for the review. I have now committed the fix and backported it to GCC 13/12/11. Maciej
Index: gcc/gcc/config/vax/vax.cc =================================================================== --- gcc.orig/gcc/config/vax/vax.cc +++ gcc/gcc/config/vax/vax.cc @@ -1831,7 +1831,9 @@ nonindexed_address_p (rtx x, bool strict } /* True if PROD is either a reg times size of mode MODE and MODE is less - than or equal 8 bytes, or just a reg if MODE is one byte. */ + than or equal 8 bytes, or just a reg if MODE is one byte. For a MULT + RTX we accept its operands in either order, however ASHIFT is not + commutative, so in that case reg has to be the left operand. */ static bool index_term_p (rtx prod, machine_mode mode, bool strict) @@ -1850,8 +1852,9 @@ index_term_p (rtx prod, machine_mode mod xfoo0 = XEXP (prod, 0); xfoo1 = XEXP (prod, 1); - if (CONST_INT_P (xfoo0) - && GET_MODE_SIZE (mode) == (log_p ? 1 << INTVAL (xfoo0) : INTVAL (xfoo0)) + if (!log_p + && CONST_INT_P (xfoo0) + && GET_MODE_SIZE (mode) == INTVAL (xfoo0) && INDEX_REGISTER_P (xfoo1, strict)) return true; Index: gcc/gcc/testsuite/gcc.dg/torture/pr111815.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/pr111815.c @@ -0,0 +1,26 @@ +/* { dg-do run } */ + +char x[] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, +}; + +__attribute__ ((noinline)) char * +p (char *a, int o, int i) +{ + return a + ++o + (1 << ++i); +} + +int +main (void) +{ + if (*p (x, 0, 0) != 3) + return 1; + if (*p (x, 1, 2) != 10) + return 1; + if (*p (x, 2, 1) != 7) + return 1; + if (*p (x, 3, 3) != 20) + return 1; + return 0; +}