This is an archive of the discontinued LLVM Phabricator instance.

[X86] Use sys::getHostCPUFeatures to improve -march=native
ClosedPublic

Authored by craig.topper on Mar 29 2015, 9:15 PM.

Details

Summary

Some versions of Sandybridge, Ivybridge, Haswell, and Broadwell CPUs don't support AVX. Currently, getHostCPUName changes the CPU name to Nehalem when it detects one of the CPUs. This also ends up disabling other features that these CPUs might still have as well as changing the scheduling model, etc.

This patch attempts to correct this by allowing the CPU name to work unaltered and then use getHostCPUFeatures to explicitly specify which features are enabled and disabled.

Similar patch will also be made to llc.

Diff Detail

Event Timeline

craig.topper retitled this revision from to [X86] Use sys::getHostCPUFeatures to improve -march=native.
craig.topper updated this object.
craig.topper edited the test plan for this revision. (Show Details)
craig.topper added a subscriber: Unknown Object (MLST).
rafael edited edge metadata.Mar 30 2015, 4:53 AM

This is fine by me, but I am not sure if I should be the one to LGTM it.

Does this make passing -target-cpu for native redundant?

The target-cpu is still used for LLVM "features" that don't have a real CPUID bit. For instance, slow-bt-mem and slow-incdec. It would also still be used to pick the scheduling model.

chandlerc accepted this revision.Mar 30 2015, 8:24 AM
chandlerc edited edge metadata.

Looks good, go for it.

This revision is now accepted and ready to land.Mar 30 2015, 8:24 AM
echristo edited edge metadata.Mar 30 2015, 9:07 AM

I think this should be ok. It'll turn some "hidden" features that would
have been "target-cpu" features into "target-features" features explicitly,
but that'll just mean wordier attribute descriptions (and will be more
accurate).

-eric