llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.01k stars 11.96k forks source link

[clang] The VecLib bitfield in CodeGenOptions.def is too small for 9 different vector libraries #108704

Open pawosm-arm opened 1 month ago

pawosm-arm commented 1 month ago

The VecLib bitfield is defined in clang/include/clang/Basic/CodeGenOptions.def as such:

// Vector functions library to use.
ENUM_CODEGENOPT(VecLib, llvm::driver::VectorLibrary, 3, llvm::driver::VectorLibrary::NoLibrary)

When this bitfield had been introduced, there were not many of the Vector Libraries to choose. Now we have 9 of them, as defined in Options.td:

def fveclib : Joined<["-"], "fveclib=">, Group<f_Group>,
  Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
    HelpText<"Use the given vector functions library">,
    Values<"Accelerate,libmvec,MASSV,SVML,SLEEF,Darwin_libsystem_m,ArmPL,AMDLIBM,none">,
    NormalizedValuesScope<"llvm::driver::VectorLibrary">,
    NormalizedValues<["Accelerate", "LIBMVEC", "MASSV", "SVML", "SLEEF",
                      "Darwin_libsystem_m", "ArmPL", "AMDLIBM", "NoLibrary"]>,
    MarshallingInfoEnum<CodeGenOpts<"VecLib">, "NoLibrary">;

In effect, they are not encoded correclty resulting in mysterious cases of the lost vectorization opportunity.

MainakSil commented 1 month ago

Please check my PR and propose any changes if required

pawosm-arm commented 1 month ago

Reopening as the fix has been reverted, 3f0dfab54184dcf9b00f37a2b8ac4f1f6ab14701

MainakSil commented 1 month ago

What happened?

AaronBallman commented 1 month ago

What happened?

We had to revert because of post-commit CI failures (you can see them in the later comments on the original PR: https://github.com/llvm/llvm-project/pull/108804)