diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2021-09-17 10:12:12 +0200 |
---|---|---|
committer | Eric Botcazou <ebotcazou@adacore.com> | 2021-09-17 10:15:38 +0200 |
commit | 687e30d9d74f5c69a54617147ce3433b07ee59ce (patch) | |
tree | 601e54497c9b1a73c55e40eaf0bb007b196addb8 /gcc/testsuite | |
parent | a5873aadb6dd749558924eba3e1b4c21755721ba (diff) | |
download | gcc-687e30d9d74f5c69a54617147ce3433b07ee59ce.zip gcc-687e30d9d74f5c69a54617147ce3433b07ee59ce.tar.gz gcc-687e30d9d74f5c69a54617147ce3433b07ee59ce.tar.bz2 |
Fix PR rtl-optimization/102306
This is a duplication of volatile loads introduced during GCC 9 development
by the 2->2 mechanism of the RTL combiner. There is already a substantial
checking for volatile references in can_combine_p but it implicitly assumes
that the combination reduces the number of instructions, which is of course
not the case here. So the fix teaches try_combine to abort the combination
when it is about to make a copy of volatile references to preserve them.
gcc/
PR rtl-optimization/102306
* combine.c (try_combine): Abort the combination if we are about to
duplicate volatile references.
gcc/testsuite/
* gcc.target/sparc/20210917-1.c: New test.
Diffstat (limited to 'gcc/testsuite')
-rw-r--r-- | gcc/testsuite/gcc.target/sparc/20210917-1.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.target/sparc/20210917-1.c b/gcc/testsuite/gcc.target/sparc/20210917-1.c new file mode 100644 index 0000000..03e8bc5 --- /dev/null +++ b/gcc/testsuite/gcc.target/sparc/20210917-1.c @@ -0,0 +1,19 @@ +/* PR rtl-optimization/102306 */ +/* Reported by Daniel Cederman <cederman@gaisler.com> */ + +/* { dg-do compile } */ +/* { dg-require-effective-target ilp32 } */ +/* { dg-options "-O -mcpu=v8" } */ + +extern void foo (void); + +void test (volatile unsigned char *a) +{ + char b = *a; + if (!b) + return; + if (b & 2) + foo (); +} + +/* { dg-final { scan-assembler-times "ldub" 1 } } */ |