aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/libclang/LibclangTest.cpp
diff options
context:
space:
mode:
authorHiroshi Inoue <inouehrs@jp.ibm.com>2018-04-21 09:32:17 +0000
committerHiroshi Inoue <inouehrs@jp.ibm.com>2018-04-21 09:32:17 +0000
commit33486787cb6e1cc9db6d24bbafaf26a91ffa91ac (patch)
tree937c0ae94767878d698b53045cb9a890f7e09dcd /clang/unittests/libclang/LibclangTest.cpp
parent6135b0fe83913370b0fc35d3afbb4e1413d85d7b (diff)
downloadllvm-33486787cb6e1cc9db6d24bbafaf26a91ffa91ac.zip
llvm-33486787cb6e1cc9db6d24bbafaf26a91ffa91ac.tar.gz
llvm-33486787cb6e1cc9db6d24bbafaf26a91ffa91ac.tar.bz2
[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
Diffstat (limited to 'clang/unittests/libclang/LibclangTest.cpp')
0 files changed, 0 insertions, 0 deletions