[all-commits] [llvm/llvm-project] dc1526: Have cpu-specific variants set 'tune-cpu' as an op...

Erich Keane via All-commits all-commits at lists.llvm.org
Mon Mar 14 06:14:42 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: dc152659b4527cc2e5f75cc33f36df67c7d5db26
      https://github.com/llvm/llvm-project/commit/dc152659b4527cc2e5f75cc33f36df67c7d5db26
  Author: Erich Keane <erich.keane at intel.com>
  Date:   2022-03-14 (Mon, 14 Mar 2022)

  Changed paths:
    M clang/include/clang/Basic/TargetInfo.h
    M clang/lib/Basic/Targets/X86.cpp
    M clang/lib/Basic/Targets/X86.h
    M clang/lib/CodeGen/CodeGenModule.cpp
    M clang/test/CodeGen/attr-cpuspecific-avx-abi.c
    M clang/test/CodeGen/attr-cpuspecific.c
    M llvm/include/llvm/Support/X86TargetParser.def

  Log Message:
  -----------
  Have cpu-specific variants set 'tune-cpu' as an optimization hint

Due to various implementation constraints, despite the programmer
choosing a 'processor' cpu_dispatch/cpu_specific needs to use the
'feature' list of a processor to identify it. This results in the
identified processor in source-code not being propogated to the
optimizer, and thus, not able to be tuned for.

This patch changes to use the actual cpu as written for tune-cpu so that
opt can make decisions based on the cpu-as-spelled, which should better
match the behavior expected by the programmer.

Note that the 'valid' list of processors for x86 is in
llvm/include/llvm/Support/X86TargetParser.def. At the moment, this list
contains only Intel processors, but other vendors may wish to add their
own entries as 'alias'es (or with different feature lists!).

If this is not done, there is two potential performance issues with the
patch, but I believe them to be worth it in light of the improvements to
behavior and performance.

1- In the event that the user spelled "ProcessorB", but we only have the
features available to test for "ProcessorA" (where A is B minus
features),
AND there is an optimization opportunity for "B" that negatively affects
"A", the optimizer will likely choose to do so.

2- In the event that the user spelled VendorI's processor, and the
feature
list allows it to run on VendorA's processor of similar features, AND
there
is an optimization opportunity for VendorIs that negatively affects
"A"s,
the optimizer will likely choose to do so. This can be fixed by adding
an
alias to X86TargetParser.def.

Differential Revision: https://reviews.llvm.org/D121410




More information about the All-commits mailing list