SuccessChanges

Summary

  1. [X86] Rename X86::getImpliedFeatures to X86::updateImpliedFeatures and pass clang's StringMap directly to it. (details)
  2. [clang-tidy] Fix bugprone-bad-signal-to-kill-thread crash when `SIGTERM` was undefined after definition. (details)
  3. [clang-tidy] Fix bugprone-bad-signal-to-kill-thread crash when `SIGTERM` is not a literal. (details)
  4. [update_cc_test_checks.py] Add test for D84511 (details)
  5. Fix qsort() interceptor for FreeBSD (details)
  6. [lit] Remove ANSI control characters from xunit output (details)
  7. [compiler-rt] Fix build of Sanitizer-Test_Nolibc after D80648 (details)
  8. [DWARFYAML][debug_info] Pull out dwarf::FormParams from DWARFYAML::Unit. (details)
  9. [clang][Driver] Don't hardcode --as-needed/--no-as-needed on Illumos (details)
  10. [NFC][InstCombine] Add tests for comparisons between x and negation of x (PR39480) (details)
  11. [InstCombine] (-NSW x) s> x  --> x s< 0  (PR39480) (details)
  12. [InstCombine] (-NSW x) ==/!= x  --> x ==/!= 0  (PR39480) (details)
  13. [InstCombine] (-NSW x) s>= x  --> x s<= 0  (PR39480) (details)
  14. [InstCombine] (-NSW x) s< x  --> x s> 0  (PR39480) (details)
  15. [InstCombine] (-NSW x) s<= x  --> x s>= 0  (PR39480) (details)
  16. [InstCombine] (-NSW x) u> x  --> x s> 0  (PR39480) (details)
  17. [InstCombine] (-NSW x) u>= x  --> x s>= 0  (PR39480) (details)
  18. [InstCombine] (-NSW x) u< x  --> x s< 0  (PR39480) (details)
  19. [InstCombine] (-NSW x) u<= x  --> x s<=0  (PR39480) (details)
  20. [NFC][InstCombine] Refactor '(-NSW x) pred x' fold (details)
  21. [lldb] Fix LLDB compilation with ncurses 6.2 due to wattr_set/get being a macro (details)
  22. [mlir] Remove most uses of LLVMDialect::getModule (details)
  23. [mlir] take MLIRContext instead of LLVMDialect in getters of LLVMType's (details)
  24. [LoopVectorizer] Inloop vector reductions (details)
Commit 504a197fe54de83be791ea0aa2ed290f6b9285b0 by craig.topper
[X86] Rename X86::getImpliedFeatures to X86::updateImpliedFeatures and pass clang's StringMap directly to it.

No point in building a vector of StringRefs for clang to apply to the
StringMap. Just pass the StringMap and modify it directly.
The file was modifiedllvm/include/llvm/Support/X86TargetParser.h
The file was modifiedclang/lib/Basic/Targets/X86.cpp
The file was modifiedllvm/lib/Support/X86TargetParser.cpp
Commit 86711668330cf48325a5e960f30d33f6a7364db2 by platonov.aleksandr
[clang-tidy] Fix bugprone-bad-signal-to-kill-thread crash when `SIGTERM` was undefined after definition.

`PP->getMacroInfo()` returns nullptr for undefined macro, which leads to null-dereference at `MI->tockens().back()`.
Stack dump:
```
#0 0x000000000217d15a llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/llvm-project/build/bin/clang-tidy+0x217d15a)
#1 0x000000000217b17c llvm::sys::RunSignalHandlers() (/llvm-project/build/bin/clang-tidy+0x217b17c)
#2 0x000000000217b2e3 SignalHandler(int) (/llvm-project/build/bin/clang-tidy+0x217b2e3)
#3 0x00007f39be5b1390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)
#4 0x0000000000593532 clang::tidy::bugprone::BadSignalToKillThreadCheck::check(clang::ast_matchers::MatchFinder::MatchResult const&) (/llvm-project/build/bin/clang-tidy+0x593532)
```

Reviewed By: hokein

Differential Revision: https://reviews.llvm.org/D85401
The file was modifiedclang-tools-extra/clang-tidy/bugprone/BadSignalToKillThreadCheck.cpp
The file was addedclang-tools-extra/test/clang-tidy/checkers/bugprone-bad-signal-to-kill-thread-undef-sigterm.cpp
Commit 216ad2da74f0e952af8f1c8ac84e19146d739ff2 by platonov.aleksandr
[clang-tidy] Fix bugprone-bad-signal-to-kill-thread crash when `SIGTERM` is not a literal.

If `SIGTERM` is not a literal (e.g. `#define SIGTERM ((unsigned)15)`) bugprone-bad-signal-to-kill-thread check crashes.
Stack dump:
```
#0 0x000000000217d15a llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/llvm-project/build/bin/clang-tidy+0x217d15a)
#1 0x000000000217b17c llvm::sys::RunSignalHandlers() (/llvm-project/build/bin/clang-tidy+0x217b17c)
#2 0x000000000217b2e3 SignalHandler(int) (/llvm-project/build/bin/clang-tidy+0x217b2e3)
#3 0x00007f6a7efb1390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)
#4 0x000000000212ac9b llvm::StringRef::getAsInteger(unsigned int, llvm::APInt&) const (/llvm-project/build/bin/clang-tidy+0x212ac9b)
#5 0x0000000000593501 clang::tidy::bugprone::BadSignalToKillThreadCheck::check(clang::ast_matchers::MatchFinder::MatchResult const&) (/llvm-project/build/bin/clang-tidy+0x593501)
```

Reviewed By: hokein

Differential Revision: https://reviews.llvm.org/D85398
The file was addedclang-tools-extra/test/clang-tidy/checkers/bugprone-bad-signal-to-kill-thread-sigterm-not-a-literal.cpp
The file was modifiedclang-tools-extra/clang-tidy/bugprone/BadSignalToKillThreadCheck.cpp
Commit e150d2cab8688a2b3b7d395bfbbc152b08df9033 by Alexander.Richardson
[update_cc_test_checks.py] Add test for D84511

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D85115
The file was modifiedclang/test/utils/update_cc_test_checks/basic-cplusplus.test
The file was modifiedclang/test/utils/update_cc_test_checks/lit.local.cfg
Commit 8803ebcf3b562172687321318c423f39f22b2e5b by Alexander.Richardson
Fix qsort() interceptor for FreeBSD

When the FreeBSD qsort() implementation recurses, it does so using an
interposable function call, so we end up calling the interceptor again
and set the saved comparator to wrapped_qsort_compar. This results in an
infinite loop and a eventually a stack overflow since wrapped_qsort_compar
ends up calling itself. This means that ASAN is completely broken on
FreeBSD for programs that call qsort(). I found this while running
check-all on a FreeBSD system a ASAN-instrumented LLVM.

Fix this by checking whether we are recursing inside qsort before writing
to qsort_compar. The same bug exists in the qsort_r interceptor, so use the
same approach there. I did not test the latter since the qsort_r function
signature does not match and therefore it's not intercepted on FreeBSD/macOS.

Fixes https://llvm.org/PR46832

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D84509
The file was modifiedcompiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
The file was addedcompiler-rt/test/sanitizer_common/TestCases/Posix/recursion-in-qsort.cpp
Commit 3b3cdcc7a557a7dbd53e9e8cc311247d6df46c5c by Alexander.Richardson
[lit] Remove ANSI control characters from xunit output

Failing test output sometimes contains control characters like \x1b (e.g.
if there was some -fcolor-diagnostics output) which are not allowed inside
XML files. This causes problems with CI systems: for example, the Jenkins
JUnit XML will throw an exception when ecountering those characters and
similar problems also occur with GitLab CI.

Reviewed By: yln, jdenny

Differential Revision: https://reviews.llvm.org/D84233
The file was modifiedllvm/utils/lit/lit/reports.py
The file was addedllvm/utils/lit/tests/Inputs/shtest-format/external_shell/fail_with_control_chars.txt
The file was modifiedllvm/utils/lit/tests/shtest-format.py
The file was addedllvm/utils/lit/tests/Inputs/shtest-format/external_shell/write-control-chars.py
Commit 6148cca70888ead020a808279043fd013ca72a2a by Alexander.Richardson
[compiler-rt] Fix build of Sanitizer-Test_Nolibc after D80648

Running ninja check-sanitizer fails for after that patch (commit
058f5f6fd813d1ee1480497394d6fd44e65ec62b) with the following error:

libRTSanitizerCommon.test.nolibc.x86_64.a(sanitizer_posix.cpp.o): In
function `__sanitizer::GetNamedMappingFd(char const*, unsigned long,
int*)':
..../llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_posix.cpp:358:
undefined reference to `fcntl'
clang-12: error: linker command failed with exit code 1 (use -v to see
invocation)

This patch works around the problem by only calling fcntl if O_CLOEXEC
is not defined.

Reviewed By: plopresti

Differential Revision: https://reviews.llvm.org/D85114
The file was modifiedcompiler-rt/lib/sanitizer_common/sanitizer_posix.cpp
Commit 4357986b411dd164932c66ebfe4a9cf96a7d74cd by Xing
[DWARFYAML][debug_info] Pull out dwarf::FormParams from DWARFYAML::Unit.

Unit.Format, Unit.Version and Unit.AddrSize are replaced with
dwarf::FormParams in D84496 to get rid of unnecessary functions
getOffsetSize() and getRefSize(). However, that change makes it
difficult to make AddrSize optional (Optional<uint8_t>). This change
pulls out dwarf::FormParams from DWARFYAML::Unit and use it as a helper
struct in DWARFYAML::emitDebugInfo().

Reviewed By: jhenderson, MaskRay

Differential Revision: https://reviews.llvm.org/D85296
The file was modifiedllvm/lib/ObjectYAML/DWARFYAML.cpp
The file was modifiedllvm/tools/obj2yaml/dwarf2yaml.cpp
The file was modifiedllvm/include/llvm/ObjectYAML/DWARFYAML.h
The file was modifiedllvm/lib/ObjectYAML/DWARFEmitter.cpp
Commit 710949482edb96a329104317164909979f2387aa by ro
[clang][Driver] Don't hardcode --as-needed/--no-as-needed on Illumos

`ninja check-all` currently fails on Illumos:

  [84/716] Generating default/Asan-i386-inline-Test
  FAILED: projects/compiler-rt/lib/asan/tests/default/Asan-i386-inline-Test
  cd /var/llvm/dist-amd64-release/projects/compiler-rt/lib/asan/tests && /var/llvm/dist-amd64-release/./bin/clang ASAN_INST_TEST_OBJECTS.gtest-all.cc.i386-inline.o ASAN_INST_TEST_OBJECTS.asan_globals_test.cpp.i386-inline.o ASAN_INST_TEST_OBJECTS.asan_interface_test.cpp.i386-inline.o ASAN_INST_TEST_OBJECTS.asan_internal_interface_test.cpp.i386-inline.o ASAN_INST_TEST_OBJECTS.asan_test.cpp.i386-inline.o ASAN_INST_TEST_OBJECTS.asan_oob_test.cpp.i386-inline.o ASAN_INST_TEST_OBJECTS.asan_mem_test.cpp.i386-inline.o ASAN_INST_TEST_OBJECTS.asan_str_test.cpp.i386-inline.o ASAN_INST_TEST_OBJECTS.asan_test_main.cpp.i386-inline.o -o /var/llvm/dist-amd64-release/projects/compiler-rt/lib/asan/tests/default/./Asan-i386-inline-Test -g --driver-mode=g++ -fsanitize=address -m32
  ld: fatal: unrecognized option '--no-as-needed'
  ld: fatal: use the -z help option for usage information
  clang-11: error: linker command failed with exit code 1 (use -v to see invocation)

`clang` unconditionally passes `--as-needed`/`--no-as-needed` to the
linker.  This works on Solaris 11.[34] which added a couple of option
aliases to the native linker to improve compatibility with GNU `ld`.
Illumos `ld` didn't do this, so one needs to use the corresponding
native options `-z ignore`/`-z record` instead.

Because this works on both Solaris and Illumos, the current patch always
passes the native options on Solaris.  This isn't fully correct, however:
when using GNU `ld` on Solaris (not yet supported; I'm working on that),
one still needs `--as-needed` instead.

I'm hardcoding this decision because a generic detection via a `cmake` test
is hard: many systems have their own implementation of `getDefaultLinker`
and `cmake` would have to duplicate the information encoded there.
Besides, it would still break when `-fuse-ld` is used.

Tested on `amd64-pc-solaris2.11` (Solaris 11.4 and OpenIndiana 2020.04),
`sparcv9-sun-solaris2.11`, and `x86_64-pc-linux-gnu`.

Differential Revision: https://reviews.llvm.org/D84412
The file was modifiedclang/lib/Driver/ToolChains/CommonArgs.cpp
Commit 664e1784cd5ee742d74a95a018986e02d66908eb by lebedev.ri
[NFC][InstCombine] Add tests for comparisons between x and negation of x (PR39480)
The file was addedllvm/test/Transforms/InstCombine/cmp-x-vs-neg-x.ll
Commit 5060f5682b011d2a8c708b3c1b16bd4e0c408afb by lebedev.ri
[InstCombine] (-NSW x) s> x  --> x s< 0  (PR39480)

Name: (-x) s> x  -->  x s< 0
%neg_x = sub nsw i8 0, %x ; %x must not be INT_MIN
%r = icmp sgt i8 %neg_x, %x
  =>
%r = icmp slt i8 %x, 0

https://rise4fun.com/Alive/ZslD

https://bugs.llvm.org/show_bug.cgi?id=39480
The file was modifiedllvm/test/Transforms/InstCombine/cmp-x-vs-neg-x.ll
The file was modifiedllvm/include/llvm/IR/PatternMatch.h
The file was modifiedllvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
Commit 8878b79cfe99e1ef36a265539329cd323e05a40d by lebedev.ri
[InstCombine] (-NSW x) ==/!= x  --> x ==/!= 0  (PR39480)

Name: (-x) == x  -->  x == 0
%neg_x = sub nsw i8 0, %x ; %x must not be INT_MIN
%r = icmp eq i8 %neg_x, %x
  =>
%r = icmp eq i8 %x, 0

Name: (-x) != x  -->  x != 0
%neg_x = sub nsw i8 0, %x ; %x must not be INT_MIN
%r = icmp ne i8 %neg_x, %x
  =>
%r = icmp ne i8 %x, 0

https://rise4fun.com/Alive/4slH

https://bugs.llvm.org/show_bug.cgi?id=39480
The file was modifiedllvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
The file was modifiedllvm/test/Transforms/InstCombine/cmp-x-vs-neg-x.ll
Commit 388520765157f1ce7e48e49179dc58781ae61f56 by lebedev.ri
[InstCombine] (-NSW x) s>= x  --> x s<= 0  (PR39480)

Name: (-x) s>= x  -->  x s<= 0
%neg_x = sub nsw i8 0, %x ; %x must not be INT_MIN
%r = icmp sge i8 %neg_x, %x
  =>
%r = icmp sle i8 %x, 0

https://rise4fun.com/Alive/Hdip

https://bugs.llvm.org/show_bug.cgi?id=39480
The file was modifiedllvm/test/Transforms/InstCombine/cmp-x-vs-neg-x.ll
The file was modifiedllvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
Commit 01a6c4bd26a599e877301568f77eb835d0a6e812 by lebedev.ri
[InstCombine] (-NSW x) s< x  --> x s> 0  (PR39480)

Name: (-x) s< x  -->  x > 0
%neg_x = sub nsw i8 0, %x ; %x must not be INT_MIN
%r = icmp slt i8 %neg_x, %x
  =>
%r = icmp sgt i8 %x, 0

https://rise4fun.com/Alive/3IXb

https://bugs.llvm.org/show_bug.cgi?id=39480
The file was modifiedllvm/test/Transforms/InstCombine/cmp-x-vs-neg-x.ll
The file was modifiedllvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
Commit 59387c0dd742be037a0393e8fef7fdffdbb84ec4 by lebedev.ri
[InstCombine] (-NSW x) s<= x  --> x s>= 0  (PR39480)

Name: (-x) s<= x  -->  x >= 0
%neg_x = sub nsw i8 0, %x ; %x must not be INT_MIN
%r = icmp sle i8 %neg_x, %x
  =>
%r = icmp sge i8 %x, 0

https://rise4fun.com/Alive/91k

https://bugs.llvm.org/show_bug.cgi?id=39480
The file was modifiedllvm/test/Transforms/InstCombine/cmp-x-vs-neg-x.ll
The file was modifiedllvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
Commit 16c642fa39d50dd066e364e0f258140a3dbaa64b by lebedev.ri
[InstCombine] (-NSW x) u> x  --> x s> 0  (PR39480)

Name: (-x) u> x  -->  x s> 0
%neg_x = sub nsw i8 0, %x ; %x must not be INT_MIN
%r = icmp ugt i8 %neg_x, %x
  =>
%r = icmp sgt i8 %x, 0

https://rise4fun.com/Alive/Raea

https://bugs.llvm.org/show_bug.cgi?id=39480
The file was modifiedllvm/test/Transforms/InstCombine/cmp-x-vs-neg-x.ll
The file was modifiedllvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
Commit 0e1241a3c9881d5cb3280bdb0c36712fae957694 by lebedev.ri
[InstCombine] (-NSW x) u>= x  --> x s>= 0  (PR39480)

Name: (-x) u>= x  -->  x s>= 0
%neg_x = sub nsw i8 0, %x ; %x must not be INT_MIN
%r = icmp uge i8 %neg_x, %x
  =>
%r = icmp sge i8 %x, 0

https://rise4fun.com/Alive/LLHd

https://bugs.llvm.org/show_bug.cgi?id=39480
The file was modifiedllvm/test/Transforms/InstCombine/cmp-x-vs-neg-x.ll
The file was modifiedllvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
Commit 132be1f502778ea8abd5f214908fc19d8535d786 by lebedev.ri
[InstCombine] (-NSW x) u< x  --> x s< 0  (PR39480)

Name: (-x) u< x  -->  x s< 0
%neg_x = sub nsw i8 0, %x ; %x must not be INT_MIN
%r = icmp ult i8 %neg_x, %x
  =>
%r = icmp slt i8 %x, 0

https://rise4fun.com/Alive/zSuf

https://bugs.llvm.org/show_bug.cgi?id=39480
The file was modifiedllvm/test/Transforms/InstCombine/cmp-x-vs-neg-x.ll
The file was modifiedllvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
Commit 141357663e671636392c9973025ea723f423a9c4 by lebedev.ri
[InstCombine] (-NSW x) u<= x  --> x s<=0  (PR39480)

Name: (-x) u<= x  -->  x s<= 0
%neg_x = sub nsw i8 0, %x ; %x must not be INT_MIN
%r = icmp ule i8 %neg_x, %x
  =>
%r = icmp sle i8 %x, 0

https://rise4fun.com/Alive/V22

https://bugs.llvm.org/show_bug.cgi?id=39480
The file was modifiedllvm/test/Transforms/InstCombine/cmp-x-vs-neg-x.ll
The file was modifiedllvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
Commit a512c894768ba681721cb2fc5159294cec810f0a by lebedev.ri
[NFC][InstCombine] Refactor '(-NSW x) pred x' fold
The file was modifiedllvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
Commit d40c44e89e11659439072a4b57d2c0c191d5cae5 by Raphael Isemann
[lldb] Fix LLDB compilation with ncurses 6.2 due to wattr_set/get being a macro

My ncurses 6.2 arch defines those two functions as macros, so the scope operator
doesn't work here.
The file was modifiedlldb/source/Core/IOHandlerCursesGUI.cpp
Commit d3a9807674c1d7000bd5ec4028be399c81cbd098 by zinenko
[mlir] Remove most uses of LLVMDialect::getModule

This prepares for the removal of llvm::Module and LLVMContext from the
mlir::LLVMDialect.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D85371
The file was modifiedmlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td
The file was modifiedmlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp
The file was modifiedmlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
The file was modifiedmlir/lib/Conversion/VectorToROCDL/VectorToROCDL.cpp
The file was modifiedmlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h
The file was modifiedmlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
The file was modifiedmlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
The file was modifiedmlir/lib/Conversion/GPUToVulkan/ConvertLaunchFuncToVulkanCalls.cpp
Commit 5446ec8507080ac075274a30c7cf25652d9a860f by zinenko
[mlir] take MLIRContext instead of LLVMDialect in getters of LLVMType's

Historical modeling of the LLVM dialect types had been wrapping LLVM IR types
and therefore needed access to the instance of LLVMContext stored in the
LLVMDialect. The new modeling does not rely on that and only needs the
MLIRContext that is used for uniquing, similarly to other MLIR types. Change
LLVMType::get<Kind>Ty functions to take `MLIRContext *` instead of
`LLVMDialect *` as first argument. This brings the code base closer to
completely removing the dependence on LLVMContext from the LLVMDialect,
together with additional support for thread-safety of its use.

Depends On D85371

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D85372
The file was modifiedmlir/lib/Dialect/LLVMIR/IR/ROCDLDialect.cpp
The file was modifiedmlir/lib/Conversion/GPUToVulkan/ConvertLaunchFuncToVulkanCalls.cpp
The file was modifiedmlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
The file was modifiedmlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h
The file was modifiedmlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp
The file was modifiedmlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
The file was modifiedmlir/include/mlir/Dialect/LLVMIR/LLVMTypes.h
The file was modifiedmlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp
The file was modifiedmlir/lib/Conversion/GPUCommon/GPUOpsLowering.h
The file was modifiedmlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
The file was modifiedmlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp
The file was modifiedmlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td
The file was modifiedmlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
The file was modifiedmlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp
The file was modifiedmlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp
The file was modifiedmlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp
The file was modifiedmlir/lib/Conversion/GPUCommon/IndexIntrinsicsOpLowering.h
The file was modifiedmlir/lib/Conversion/GPUCommon/OpToFuncCallLowering.h
The file was modifiedmlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
Commit 745bf6cf447110ae025e1c77338020f0c5d5ca80 by david.green
[LoopVectorizer] Inloop vector reductions

Arm MVE has multiple instructions such as VMLAVA.s8, which (in this
case) can take two 128bit vectors, sign extend the inputs to i32,
multiplying them together and sum the result into a 32bit general
purpose register. So taking 16 i8's as inputs, they can multiply and
accumulate the result into a single i32 without any rounding/truncating
along the way. There are also reduction instructions for plain integer
add and min/max, and operations that sum into a pair of 32bit registers
together treated as a 64bit integer (even though MVE does not have a
plain 64bit addition instruction). So giving the vectorizer the ability
to use these instructions both enables us to vectorize at higher
bitwidths, and to vectorize things we previously could not.

In order to do that we need a way to represent that the reduction
operation, specified with a llvm.experimental.vector.reduce when
vectorizing for Arm, occurs inside the loop not after it like most
reductions. This patch attempts to do that, teaching the vectorizer
about in-loop reductions. It does this through a vplan recipe
representing the reductions that the original chain of reduction
operations is replaced by. Cost modelling is currently just done through
a prefersInloopReduction TTI hook (which follows in a later patch).

Differential Revision: https://reviews.llvm.org/D75069
The file was modifiedllvm/lib/Transforms/Vectorize/VPlan.h
The file was modifiedllvm/test/Transforms/LoopVectorize/reduction-inloop.ll
The file was modifiedllvm/lib/Transforms/Vectorize/LoopVectorize.cpp
The file was modifiedllvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h
The file was modifiedllvm/lib/Analysis/IVDescriptors.cpp
The file was modifiedllvm/lib/Transforms/Vectorize/VPlan.cpp
The file was modifiedllvm/test/Transforms/LoopVectorize/reduction-inloop-uf4.ll
The file was modifiedllvm/include/llvm/Analysis/IVDescriptors.h