1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00
Go to file
Ahmed Bougacha c6b1c28e14 [X86] Don't turn (c?-v:v) into (c?-v:0) by blindly using PSIGN.
Currently, we sometimes miscompile this vector pattern:
    (c ? -v : v)
We lower it to (because "c" is <4 x i1>, lowered as a vector mask):
    (~c & v) | (c & -v)

When we have SSSE3, we incorrectly lower that to PSIGN, which does:
    (c < 0 ? -v : c > 0 ? v : 0)
in other words, when c is either all-ones or all-zero:
    (c ? -v : 0)
While this is an old bug, it rarely triggers because the PSIGN combine
is too sensitive to operand order. This will be improved separately.

Note that the PSIGN tests are also incorrect. Consider:
    %b.lobit = ashr <4 x i32> %b, <i32 31, i32 31, i32 31, i32 31>
    %sub = sub nsw <4 x i32> zeroinitializer, %a
    %0 = xor <4 x i32> %b.lobit, <i32 -1, i32 -1, i32 -1, i32 -1>
    %1 = and <4 x i32> %a, %0
    %2 = and <4 x i32> %b.lobit, %sub
    %cond = or <4 x i32> %1, %2
    ret <4 x i32> %cond
if %b is zero:
    %b.lobit = <4 x i32> zeroinitializer
    %sub = sub nsw <4 x i32> zeroinitializer, %a
    %0 = <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>
    %1 = <4 x i32> %a
    %2 = <4 x i32> zeroinitializer
    %cond = or <4 x i32> %a, zeroinitializer
    ret <4 x i32> %a
whereas we currently generate:
    psignd %xmm1, %xmm0
    retq
which returns 0, as %xmm1 is 0.

Instead, use a pure logic sequence, as described in:
https://graphics.stanford.edu/~seander/bithacks.html#ConditionalNegate

Fixes PR26110.

Differential Revision: http://reviews.llvm.org/D17181

llvm-svn: 261023
2016-02-16 22:14:03 +00:00
bindings Kill LLVMAddTargetData 2016-02-16 00:22:02 +00:00
cmake cmake: Simplify the iOS.cmake toolchain 2016-02-12 23:36:05 +00:00
docs Deprecate LLVMGetDataLayout and replace it by LLVMGetDataLayoutStr 2016-02-16 00:23:52 +00:00
examples Remove autoconf support 2016-01-26 21:29:08 +00:00
include [Hexagon] Adding relocation for code size, cold path optimization allowing a 23-bit 4-byte aligned relocation to be a valid instruction encoding. 2016-02-16 20:38:17 +00:00
lib [X86] Don't turn (c?-v:v) into (c?-v:0) by blindly using PSIGN. 2016-02-16 22:14:03 +00:00
projects Remove autoconf support 2016-01-26 21:29:08 +00:00
resources In MSVC builds embed a VERSIONINFO resource in our exe and DLL files. 2015-06-12 15:58:29 +00:00
test [X86] Don't turn (c?-v:v) into (c?-v:0) by blindly using PSIGN. 2016-02-16 22:14:03 +00:00
tools Pass a std::unique_ptr to IRMover::move. 2016-02-16 18:50:12 +00:00
unittests Remove an unnecessary std::move to fix -Wpessimizing-move warning. 2016-02-16 04:17:42 +00:00
utils [TableGen] Fix inconsistent spacing. NFC 2016-02-16 04:24:58 +00:00
.arcconfig Updated phabricator server. 2014-04-07 03:57:04 +00:00
.clang-format Test commit. 2014-03-02 13:08:46 +00:00
.clang-tidy adding readability-identifier-naming to llvm clang-tidy configuration. 2015-12-08 17:44:51 +00:00
.gitignore Minor updates to gitignore so that symlinks are ignored in the projects dir. 2015-07-07 20:24:58 +00:00
CMakeLists.txt [CMake] Add a macro definition to detect if we are building GlobalISel: 2016-02-10 23:00:57 +00:00
CODE_OWNERS.TXT [docs] Remove references to autotools build. 2016-01-30 01:10:15 +00:00
configure Remove autoconf support 2016-01-26 21:29:08 +00:00
CREDITS.TXT [WebAssembly] Initial WebAssembly backend 2015-06-29 23:51:55 +00:00
LICENSE.TXT Update for a new year. 2015-03-12 01:25:29 +00:00
llvm.spec.in [Sparc] Implement i64 load/store support for 32-bit sparc. 2015-08-10 19:11:39 +00:00
LLVMBuild.txt
README.txt Revert previous test commit. 2016-01-04 19:13:29 +00:00

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.