This is an archive of the discontinued LLVM Phabricator instance.

[SPEC2017] Use -fno-strict-aliasing when compiling 502.gcc_r, 505.mcf_r
ClosedPublic

Authored by labrinea on Jan 11 2023, 2:20 AM.

Details

Summary

As suggested on SPEC's documentation page (Known Portability Issues) [1][2] the spec_qsort.c routine does not strictly obey the ANSI aliasing rules. In the absence of -fno-strict-aliasing the test suite fails when Function Specialization is enabled with both LTO and PGO (see https://reviews.llvm.org/D140210).

[1] https://www.spec.org/cpu2017/Docs/benchmarks/502.gcc_r.html
[2] https://www.spec.org/cpu2017/Docs/benchmarks/505.mcf_r.html

Diff Detail

Repository
rT test-suite

Event Timeline

labrinea created this revision.Jan 11 2023, 2:20 AM
labrinea requested review of this revision.Jan 11 2023, 2:20 AM

Hmm, I am wondering whether I should add the flag to 505.mcf_r too, despite it's not failing.

xbolva00 accepted this revision.Jan 11 2023, 3:39 AM
xbolva00 added a subscriber: xbolva00.

Hmm, I am wondering whether I should add the flag to 505.mcf_r too, despite it's not failing.

Should be added later, when needed.

This revision is now accepted and ready to land.Jan 11 2023, 3:39 AM

Why not adding it now for MCF as well? It's clear that this is a potential problem, so adding it now may save someone some time looking into this when it does start failing.

fhahn added a comment.Jan 11 2023, 4:01 AM

Is this change perf-neutral?

SjoerdMeijer added a comment.EditedJan 11 2023, 4:30 AM

It's not entirely perf neutral last time I actually played with this a couple of weeks ago. I can't remember exactly, but about 0.5% difference or so for MCF.
So nothing shocking I think, and I think we have a good reason to add it.

xbolva00 added a comment.EditedJan 11 2023, 5:11 AM

Why not adding it now for MCF as well? It's clear that this is a potential problem, so adding it now may save someone some time looking into this when it does start failing.

The questions is why there is no such failure for mcf currently... no func specialization for this benchmark in spec_qsort? But from the description it should happen

Measured +9.121% score increase for 505.mcf_r from SPEC Int 2017
(Tested on Neoverse N1 with -O3 + LTO)

So in this case yes, you should add this flag for mcf too.

Is this change perf-neutral?

I am not seeing much impact on performance. The score differences seem noisy (average of first three runs). On AArch64 -O3 + LTO (no PGO) I am seeing:

-fstrict-aliasing --> -fno-strict-aliasing

testnameFuncSpec=Off FuncSpec=On
505.mcf_r+ 0.101 %+ 0.092 %
502.gcc_r+ 0.085 %- 0.189 %

That said I will be adding the flag to 505.mcf_r too.

labrinea updated this revision to Diff 488581.Jan 12 2023, 3:15 AM
labrinea retitled this revision from [SPEC2017] Use -fno-strict-aliasing when compiling 502.gcc_r. to [SPEC2017] Use -fno-strict-aliasing when compiling 502.gcc_r, 505.mcf_r.
labrinea edited the summary of this revision. (Show Details)

Added the flag to 505.mcf_r as well.

SjoerdMeijer accepted this revision.Jan 12 2023, 4:00 AM

Thanks for checking the perf numbers. It matches with my experiences. I think I saw slightly bigger numbers, but yeah, like I said, nothing shocking.

I think adding this to MCF makes sense too, so LGTM.