https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102306
--- Comment #13 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-9 branch has been updated by Eric Botcazou <ebotca...@gcc.gnu.org>: https://gcc.gnu.org/g:57146bfc2459424c007f4b97f29eef4c600a7b8c commit r9-9732-g57146bfc2459424c007f4b97f29eef4c600a7b8c Author: Eric Botcazou <ebotca...@adacore.com> Date: Fri Sep 17 10:12:12 2021 +0200 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.