Am Freitag, dem 28.02.2025 um 20:21 +0100 schrieb Richard Biener: > > > Am 28.02.2025 um 20:02 schrieb Martin Uecker <uec...@tugraz.at>: > > > > Am Freitag, dem 28.02.2025 um 21:39 +0300 schrieb Alexander Monakov: > > > > On Fri, 28 Feb 2025, Martin Uecker via Gcc wrote: > > > > > > > > > > > > I have one follow-up question: What is the reason > > > > that we have stronger semantics for stores by default (i.e. > > > > when not using -fallow-store-data-races) than for reads > > > > given that the standard would allow more freedom. > > > > > > Why would it? On the contrary, it makes an explicit note that > > > introducing new writes that could create a racing store is > > > not allowed, see note 13 in C11 5.1.2.4. > > > > My original question was about inventing stores that currently > > seem to be allowed. Turning > > > > if (x != 1) > > x = 1; > > > > into > > > > x = 1; > > > > should be ok even though it invents a store for x == 1. > > > > While this technically introduces a race with another > > reader, it does so only in a seeminglessly harmless way > > when overwriting 1 with 1. > > > > Are you saying -fallow-store-data-races also introduces > > other kinds of races not allowed by C11? > > The default is -fno-allow-store-data-races
Sorry for being a bit slow. This is still not clear to me. In vect/pr65206.c the following loop can be vectorized with -fallow-store-data-races. #define N 1024 double a[N], b[N]; void foo () { for (int i = 0; i < N; ++i) if (b[i] < 3.) a[i] += b[i]; } But even though this invents stores these would still seem to be allowed by C11 because they are not detectable to another reader because they write back the same value as read. Is this understanding correct? Does -fallow-store-data-races also create other data races which would not be allowed by C11? What was the reason to disallow those optimizations that could be allowed by default? Martin > > > Martin > > > > > > > > > Only that for reads this is more difficult t o have? > > > > Or other specific reasons why data races for stores > > > > are problematic? > > > > > > Introducing racing loads is generally not harmful, see note 14. > > > > > > > > > >