This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix PR58115
- From: Richard Sandiford <rdsandiford at googlemail dot com>
- To: Bernd Edlinger <bernd dot edlinger at hotmail dot de>
- Cc: Richard Biener <richard dot guenther at gmail dot com>, Jakub Jelinek <jakub at redhat dot com>, "gcc-patches\ at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 09 Jan 2014 09:02:28 +0000
- Subject: Re: [PATCH] Fix PR58115
- Authentication-results: sourceware.org; auth=none
- References: <DUB122-W8CEA24B3CD3CF0DE08FBAE4F70 at phx dot gbl> <87iotxv211 dot fsf at talisman dot default> <20140106103000 dot GG892 at tucnak dot redhat dot com> <f1eb6537-6c08-437c-9150-938fddf37d6e at email dot android dot com> <DUB122-W13171ACEDEEC745B906363E4B70 at phx dot gbl> <87eh4kvs2e dot fsf at talisman dot default> <DUB122-W3371E3A0858FA6FEE57114E4B70 at phx dot gbl> <87wqict2i0 dot fsf at talisman dot default> <CAFiYyc0gEjjFx530yxQKa2zQ40wYKZTgYpy+mzyzX6JSnNNzdQ at mail dot gmail dot com> <DUB122-W385E58BC9A893EE82EBF4DE4B00 at phx dot gbl>
Bernd Edlinger <bernd.edlinger@hotmail.de> writes:
> I found another test case that still fails with today's trunk:
>
> #include <immintrin.h>
>
> __m256 a[10], b[10], c[10];
>
> void __attribute__((target ("sse2"), optimize (3)))
> foo (void)
> {
> }
>
> void __attribute__((target ("avx"), optimize (3)))
> bar (void)
> {
> Â a[0] = _mm256_and_ps (b[0], c[0]);
> }
>
> compile with i686-pc-linux-gnu-gcc -O2 -msse2 -mno-avx -SÂ
>
> The attached patch seems to fix this test case for
> targets that do not have SWITCHABLE_TARGET.
>
> What do you think about it?
It looks like a correct fix, but the memcpy is going to be pretty
expensive, since in most cases there will be no difference.
Calling target_reinit is the rare case, and already very slow itself,
so maybe an easier option would be to have a target_reinit counter.
I.e. for !SWITCHABLE_TARGETs only, replace TREE_OPTIMIZATION_BASE_OPTABS
with a "number of target_reinit calls" field.
Not sure it's worth the effort though. The other targets should
really move to SWITCHABLE_TARGET too. One of the reasons why I made
SWITCHABLE_TARGET optional was that I was worried it might slow down
the compiler for targets that didn't need it. Jakub's measurements
suggest that any compile-time effect is in the noise though.
> I think Jakub's patch will fix this case, but I did not try.
> However even if the i368 is now clean, there are
> still many targets that use target_reinit() in
> target_set_current_function.
FWIW I only see three others (nios, rs6000 and rx). nios and rs6000
are direct cut-&-pastes of the i386 version so should be easy to switch.
rx looks more like MIPS in that it's switching between two specific
subtargets.
Thanks,
Richard