This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [-ftree-cselim desoptimizes SH code
- From: Ian Lance Taylor <iant at google dot com>
- To: Christian BRUEL <christian dot bruel at st dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 26 Sep 2009 21:50:00 -0700
- Subject: Re: [-ftree-cselim desoptimizes SH code
- References: <4ABCA7CB.8020409@st.com>
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