[PATCH] D97116: Reduce the number of attributes attached to each function

Dávid Bolvanský via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 8 08:35:01 PDT 2021


xbolva00 added inline comments.


================
Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:496
   //    function.
-  CurFn->addFnAttr("min-legal-vector-width", llvm::utostr(LargestVectorWidth));
+  if (LargestVectorWidth)
+    CurFn->addFnAttr("min-legal-vector-width", llvm::utostr(LargestVectorWidth));
----------------
wxiao3 wrote:
> lebedev.ri wrote:
> > wxiao3 wrote:
> > > For x86 backend, "LargestVectorWidth" default value is not zero but UINT32_MAX.
> > > Please refer to: https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/X86/X86TargetMachine.cpp#L271
> > > Suggest revert this patch since it changes the code generated for x86.
> > Reproducer please?
> ```
> $ cat test.c
> void foo(float* in, float* __restrict out, int n)
> {
>     int i;
>     for (i = 0; i < n; i++) {
>         out[i] = i + 2*in[i];
>     }
> }
> ```
> 
> Before this patch
> 
> ```
> $ clang -Ofast -march=skylake-avx512 -mllvm -force-vector-width=16 -mprefer-vector-width=256 -S -o - test.c | grep ymm | wc
>      57     333    2687
> ```
> 
> After this patch
> 
> ```
> $ clang -Ofast -march=skylake-avx512 -mllvm -force-vector-width=16 -mprefer-vector-width=256 -S -o - test.c | grep ymm | wc
>       0       0       0
> ```
> 
> 
> 
Hello, reverted. https://reviews.llvm.org/rG2cb8c10342ee5d040725abb1166feb92a64c7df6


It would be good to somehow make a test to not regress in the future, but not sure how, as we have no "C -> X86 asm" tests?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97116/new/

https://reviews.llvm.org/D97116



More information about the cfe-commits mailing list