[-ftree-cselim desoptimizes SH code
Ian Lance Taylor
iant@google.com
Sun Sep 27 04:54:00 GMT 2009
Christian BRUEL <christian.bruel@st.com> writes:
> On SH, -ftree-cselim transforms a simple conditional store such as
>
> foo(int *a)
> {
> *a = 0;
> if (bar())
> *a = 1;
> }
>
> into
>
> foo(int *a)
> {
> *a = 0;
> if (! bar())
> r = *a;
> else
> r = 1;
>
> *a = r;
> }
>
> which is equivalent to add either a load or a store on the critical
> path (depending if the branch is likely to be taken or not)
I believe this transformation is invalid under the C++0x memory model.
It may introduce a race condition in a multi-threaded program. gcc
should never make this transformation unless it knows for sure that it
will turn into a conditionally executed store.
Ian
More information about the Gcc-patches
mailing list