This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix PR58115


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]