SuccessChanges

Summary

  1. [clang][Driver] Don't hardcode --as-needed/--no-as-needed on Illumos (details)
  2. [NFC][InstCombine] Add tests for comparisons between x and negation of x (PR39480) (details)
  3. [InstCombine] (-NSW x) s> x  --> x s< 0  (PR39480) (details)
  4. [InstCombine] (-NSW x) ==/!= x  --> x ==/!= 0  (PR39480) (details)
  5. [InstCombine] (-NSW x) s>= x  --> x s<= 0  (PR39480) (details)
  6. [InstCombine] (-NSW x) s< x  --> x s> 0  (PR39480) (details)
  7. [InstCombine] (-NSW x) s<= x  --> x s>= 0  (PR39480) (details)
  8. [InstCombine] (-NSW x) u> x  --> x s> 0  (PR39480) (details)
  9. [InstCombine] (-NSW x) u>= x  --> x s>= 0  (PR39480) (details)
  10. [InstCombine] (-NSW x) u< x  --> x s< 0  (PR39480) (details)
  11. [InstCombine] (-NSW x) u<= x  --> x s<=0  (PR39480) (details)
  12. [NFC][InstCombine] Refactor '(-NSW x) pred x' fold (details)
  13. [lldb] Fix LLDB compilation with ncurses 6.2 due to wattr_set/get being a macro (details)
  14. [mlir] Remove most uses of LLVMDialect::getModule (details)
  15. [mlir] take MLIRContext instead of LLVMDialect in getters of LLVMType's (details)
  16. [LoopVectorizer] Inloop vector reductions (details)
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 (diff)
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/include/llvm/IR/PatternMatch.h (diff)
The file was modifiedllvm/lib/Transforms/InstCombine/InstCombineCompares.cpp (diff)
The file was modifiedllvm/test/Transforms/InstCombine/cmp-x-vs-neg-x.ll (diff)
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/test/Transforms/InstCombine/cmp-x-vs-neg-x.ll (diff)
The file was modifiedllvm/lib/Transforms/InstCombine/InstCombineCompares.cpp (diff)
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 (diff)
The file was modifiedllvm/lib/Transforms/InstCombine/InstCombineCompares.cpp (diff)
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 (diff)
The file was modifiedllvm/lib/Transforms/InstCombine/InstCombineCompares.cpp (diff)
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/lib/Transforms/InstCombine/InstCombineCompares.cpp (diff)
The file was modifiedllvm/test/Transforms/InstCombine/cmp-x-vs-neg-x.ll (diff)
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/lib/Transforms/InstCombine/InstCombineCompares.cpp (diff)
The file was modifiedllvm/test/Transforms/InstCombine/cmp-x-vs-neg-x.ll (diff)
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 (diff)
The file was modifiedllvm/lib/Transforms/InstCombine/InstCombineCompares.cpp (diff)
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/lib/Transforms/InstCombine/InstCombineCompares.cpp (diff)
The file was modifiedllvm/test/Transforms/InstCombine/cmp-x-vs-neg-x.ll (diff)
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/lib/Transforms/InstCombine/InstCombineCompares.cpp (diff)
The file was modifiedllvm/test/Transforms/InstCombine/cmp-x-vs-neg-x.ll (diff)
Commit a512c894768ba681721cb2fc5159294cec810f0a by lebedev.ri
[NFC][InstCombine] Refactor '(-NSW x) pred x' fold
The file was modifiedllvm/lib/Transforms/InstCombine/InstCombineCompares.cpp (diff)
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 (diff)
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/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp (diff)
The file was modifiedmlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td (diff)
The file was modifiedmlir/lib/Conversion/GPUToVulkan/ConvertLaunchFuncToVulkanCalls.cpp (diff)
The file was modifiedmlir/lib/Conversion/VectorToROCDL/VectorToROCDL.cpp (diff)
The file was modifiedmlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h (diff)
The file was modifiedmlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp (diff)
The file was modifiedmlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp (diff)
The file was modifiedmlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp (diff)
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/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp (diff)
The file was modifiedmlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp (diff)
The file was modifiedmlir/lib/Conversion/GPUCommon/GPUOpsLowering.h (diff)
The file was modifiedmlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h (diff)
The file was modifiedmlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp (diff)
The file was modifiedmlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp (diff)
The file was modifiedmlir/lib/Conversion/GPUToVulkan/ConvertLaunchFuncToVulkanCalls.cpp (diff)
The file was modifiedmlir/lib/Conversion/GPUCommon/OpToFuncCallLowering.h (diff)
The file was modifiedmlir/include/mlir/Dialect/LLVMIR/LLVMOps.td (diff)
The file was modifiedmlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp (diff)
The file was modifiedmlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td (diff)
The file was modifiedmlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp (diff)
The file was modifiedmlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp (diff)
The file was modifiedmlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp (diff)
The file was modifiedmlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp (diff)
The file was modifiedmlir/lib/Dialect/LLVMIR/IR/ROCDLDialect.cpp (diff)
The file was modifiedmlir/include/mlir/Dialect/LLVMIR/LLVMTypes.h (diff)
The file was modifiedmlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp (diff)
The file was modifiedmlir/lib/Conversion/GPUCommon/IndexIntrinsicsOpLowering.h (diff)
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/LoopVectorizationPlanner.h (diff)
The file was modifiedllvm/lib/Transforms/Vectorize/VPlan.h (diff)
The file was modifiedllvm/lib/Transforms/Vectorize/VPlan.cpp (diff)
The file was modifiedllvm/include/llvm/Analysis/IVDescriptors.h (diff)
The file was modifiedllvm/lib/Transforms/Vectorize/LoopVectorize.cpp (diff)
The file was modifiedllvm/test/Transforms/LoopVectorize/reduction-inloop-uf4.ll (diff)
The file was modifiedllvm/lib/Analysis/IVDescriptors.cpp (diff)
The file was modifiedllvm/test/Transforms/LoopVectorize/reduction-inloop.ll (diff)