llvm-project/llvm
Hiroshi Inoue 33486787cb [PowerPC] fix incorrect vectorization of abs() on POWER9
Vectorized loops with abs() returns incorrect results on POWER9. This patch fixes it.
For example the following code returns negative result if input values are negative though it sums up the absolute value of the inputs.

int vpx_satd_c(const int16_t *coeff, int length) {
  int satd = 0;
  for (int i = 0; i < length; ++i) satd += abs(coeff[i]);
  return satd;
}

This problem causes test failures for libvpx.
For vector absolute and vector absolute difference on POWER9, LLVM generates VABSDUW (Vector Absolute Difference Unsigned Word) instruction or variants.
Since these instructions are for unsigned integers, we need adjustment for signed integers.
For abs(sub(a, b)), we generate VABSDUW(a+0x80000000, b+0x80000000). Otherwise, abs(sub(-1, 0)) returns 0xFFFFFFFF(=-1) instead of 1. For abs(a), we generate VABSDUW(a+0x80000000, 0x80000000).

Differential Revision: https://reviews.llvm.org/D45522

llvm-svn: 330497
2018-04-21 09:32:17 +00:00
..
bindings [llgo] Move SetSubprogram 2018-04-07 16:26:59 +00:00
cmake [cmake] Improve pthread_[gs]etname_np detection code 2018-04-18 13:13:27 +00:00
docs [DAGCombine] (float)((int) f) --> ftrunc (PR36617) 2018-04-20 15:07:55 +00:00
examples [ORC] Create a new SymbolStringPool by default in ExecutionSession constructor. 2018-04-02 20:57:56 +00:00
include Remove unused argument from emitModuleMetadata. 2018-04-20 19:07:57 +00:00
lib [PowerPC] fix incorrect vectorization of abs() on POWER9 2018-04-21 09:32:17 +00:00
projects
resources
runtimes [CMake][runtimes] Process common options in runtimes build 2018-04-11 05:18:03 +00:00
test [PowerPC] fix incorrect vectorization of abs() on POWER9 2018-04-21 09:32:17 +00:00
tools [llvm-objcopy] Fix sh_link 2018-04-20 20:46:04 +00:00
unittests Revert "Revert r330403 and r330413." 2018-04-20 13:34:32 +00:00
utils Remove llvm-build's --configure-target-def-file. 2018-04-20 17:21:10 +00:00
.arcconfig
.clang-format
.clang-tidy
.gitattributes
.gitignore
CMakeLists.txt [llvm-exegesis] Add a flag to disable libpfm even if present. 2018-04-11 07:32:43 +00:00
CODE_OWNERS.TXT CODE_OWNERS: Take code ownership of llvm-mca. 2018-04-20 10:16:31 +00:00
CREDITS.TXT
LICENSE.TXT
LLVMBuild.txt
README.txt
RELEASE_TESTERS.TXT
configure
llvm.spec.in

README.txt

Low Level Virtual Machine (LLVM)
================================

This directory and its subdirectories contain source code for LLVM,
a toolkit for the construction of highly optimized compilers,
optimizers, and runtime environments.

LLVM is open source software. You may freely distribute it under the terms of
the license agreement found in LICENSE.txt.

Please see the documentation provided in docs/ for further
assistance with LLVM, and in particular docs/GettingStarted.rst for getting
started with LLVM and docs/README.txt for an overview of LLVM's
documentation setup.

If you are writing a package for LLVM, see docs/Packaging.rst for our
suggestions.