This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Possible bug in cse.c affecting pre/post-modify mem access
- From: "A. Skrobov" <tyomitch at gmail dot com>
- To: gcc at gcc dot gnu dot org
- Date: Thu, 10 May 2018 22:44:45 +0300
- Subject: Possible bug in cse.c affecting pre/post-modify mem access
Hello,
While working on a port of GCC for a non-public architecture that has
pre/post-modify memory access instructions, I discovered what looks
like a bug which can cause incorrect code generation.
My suggested fix is trivial:
https://github.com/tyomitch/gcc/commit/7d9cc102adf11065358d4694109ce3e9f0b5c642
-- but I cannot submit this patch without a testcase, and my expertise
in the standard GCC target architectures is insufficient for
reproducing this bug in any one of them. So, perhaps a maintainer of
any supported architecture having pre/post-modify memory access can
take a look at this?
Basically, it seems to me that if a BB has a sequence like (using C
syntax for clarity)
r1 = r2 + 42;
r3 = *r1++;
r4 = *(r2 + 42);
--then the cse pass overlooks the modification of r1 by the second
instruction, and changes the last instruction to "r4 = *r1"