This is an archive of the discontinued LLVM Phabricator instance.

Added LLVM metadata to generated IR to increase vectorization width
ClosedPublic

Authored by emmettneyman on Aug 9 2018, 12:54 PM.

Details

Summary

Edited loop_proto_to_llvm to emit metadata at the end of the generated IR. This metadata will increase the vector width when the IR is optimized.

Diff Detail

Event Timeline

emmettneyman created this revision.Aug 9 2018, 12:54 PM
morehouse added inline comments.Aug 9 2018, 1:04 PM
clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
141

I'm not sure kArraySize is what you want here. Does "width" refer to array size or the SIMD width?

Any problem with letting the vectorizer determine this automatically?

142

Does this metadata change coverage in the vectorizer?

clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.h
18

This include should be in the cpp file.

emmettneyman added inline comments.Aug 9 2018, 1:20 PM
clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
141

The "width" refers to how wide the vector types should be in the outputted IR. So for example, a width of 64 would produce IR instructions with the type <64 x i32>.

The problem with letting the vectorizer determine the width automatically is that since the length of the arrays (and so, the number of loop iterations) is passed to the function as a parameter, the vectorizer always chooses the default width of 4 when running the loop vectorize optimization pass.

142

I'm running the coverage now, but my guess is yes. Because this metadata overrides the default behavior of the loop vectorizer, I think it will increase the coverage.

Switched the include statement to the cpp file

morehouse accepted this revision.Aug 9 2018, 1:43 PM

Code LGTM, but let's make sure this actually helps before landing.

This revision is now accepted and ready to land.Aug 9 2018, 1:43 PM

Rebased and ready to land

This revision was automatically updated to reflect the committed changes.