https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127852
Bug ID: 127852
Summary: simplify-rtx/combine can merge equal volatile accesses
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: rtl-optimization
Assignee: vineetg at gcc dot gnu.org
Reporter: vineetg at gcc dot gnu.org
Target Milestone: ---
int
dbl (volatile int *p)
{
int a = *p;
return 2 * a - *p;
}
// -O2
The MINUS coefficient fold and the `(X + 1) * Y - Y` / `(X - 1) * Y + Y` folds
merge the copies, losing one of two sequenced volatile reads.
Only x86, not seen on aarch64 because it elides `(minus (ashift (mem/v) 1)
(mem/v))` into simplify-rtx, because a load can't fold into the shift/sub on a
load/store architecture.