This is an archive of the discontinued LLVM Phabricator instance.

Reduce the number of attributes attached to each function
ClosedPublic

Authored by xbolva00 on Feb 20 2021, 3:31 AM.

Details

Summary

Patch takes advantage of the implicit default behavior to reduce the number of attributes, which in turns reduces compilation time.

Diff Detail

Event Timeline

xbolva00 created this revision.Feb 20 2021, 3:31 AM
xbolva00 requested review of this revision.Feb 20 2021, 3:31 AM
xbolva00 added a reviewer: serge-sans-paille.
xbolva00 updated this revision to Diff 325185.Feb 20 2021, 3:58 AM

I checked the usage of this attribute, and it's indeed ignored when set to zero, so yeah, let's just not generate it in that case.

This revision is now accepted and ready to land.Feb 23 2021, 8:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 23 2021, 10:09 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript

However, this commit will cause performance regression.

However, this commit will cause performance regression.

More details?

However, this commit will cause performance regression.

More details?

This commit will decrease the frequence of intel CPU, causing a performance regression.

However, this commit will cause performance regression.

More details?

This commit will decrease the frequence of intel CPU, causing a performance regression.

You'll have to be a little bit less succinct than that i'm afraid.

wxiao3 added a subscriber: wxiao3.Apr 8 2021, 2:01 AM
wxiao3 added inline comments.
clang/lib/CodeGen/CodeGenFunction.cpp
496–497

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.

pengfei added a subscriber: pengfei.Apr 8 2021, 2:13 AM
lebedev.ri added inline comments.Apr 8 2021, 2:59 AM
clang/lib/CodeGen/CodeGenFunction.cpp
496–497

Reproducer please?

wxiao3 added inline comments.Apr 8 2021, 7:34 AM
clang/lib/CodeGen/CodeGenFunction.cpp
496–497
$ 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
xbolva00 added inline comments.Apr 8 2021, 8:34 AM
clang/lib/CodeGen/CodeGenFunction.cpp
496–497

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?

clang/lib/CodeGen/CodeGenFunction.cpp