llvm-project/llvm
Craig Topper f5465f98d2 [X86] Don't emit KTEST instructions unless only the Z flag is being used
Summary:
KTEST has weird flag behavior. The Z flag is set for all bits in the AND of the k-registers being 0, and the C flag is set for all bits being 1. All other flags are cleared.

We currently emit this instruction in EmitTEST and don't check the condition code. This can lead to strange things like using the S flag after a KTEST for a signed compare.

The domain reassignment pass can also transform TEST instructions into KTEST and is not protected against the flag usage either. For now I've disabled this part of the domain reassignment pass. I tried to comment out the checks in the mir test so that we could recover them later, but I couldn't figure out how to get that to work.

This patch moves the KTEST handling into LowerSETCC and now creates a ktest+x86setcc. I've chosen this approach because I'd like to add support for the C flag for all ones in a followup patch. To do that requires that I can rewrite the condition code going in the x86setcc to be different than the original SETCC condition code.

This fixes PR36182. I'll file a PR to fix domain reassignment once this goes in. Should this be merged to 6.0?

Reviewers: spatel, guyblank, RKSimon, zvi

Reviewed By: guyblank

Subscribers: llvm-commits

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

llvm-svn: 324576
2018-02-08 07:45:55 +00:00
..
bindings [NFC] fix trivial typos in comments and documents 2018-01-26 08:15:29 +00:00
cmake Generate PDB files for profiling even in Release build. 2018-02-07 19:37:52 +00:00
docs Revert "AMDGPU: Add 32-bit constant address space" 2018-02-07 18:09:35 +00:00
examples Add OrcJIT dependency for Kaleidoscope Chapter 9. 2018-02-06 22:22:10 +00:00
include Fix PR36268. 2018-02-08 01:16:05 +00:00
lib [X86] Don't emit KTEST instructions unless only the Z flag is being used 2018-02-08 07:45:55 +00:00
projects
resources
runtimes [CMake] Support for cross-compilation when build runtimes 2018-01-08 23:50:59 +00:00
test [X86] Don't emit KTEST instructions unless only the Z flag is being used 2018-02-08 07:45:55 +00:00
tools gold-plugin: Do not set codegen opt level based on LTO opt level. 2018-02-08 02:41:22 +00:00
unittests Revert "[DebugInfo] Improvements to representation of enumeration types (PR36168)" 2018-02-07 20:28:47 +00:00
utils [CodeGenSchedule][NFC] Always emit ProcResourceUnits. 2018-02-05 12:23:51 +00:00
.arcconfig [llvm] Set up .arcconfig to point to Diffusion L repository 2018-01-12 15:37:41 +00:00
.clang-format
.clang-tidy
.gitattributes
.gitignore
CMakeLists.txt CMAKE: apply -O3 for mingw clang 2018-02-08 07:13:17 +00:00
CODE_OWNERS.TXT
CREDITS.TXT Add myself to CREDITS.txt 2018-01-29 17:02:34 +00:00
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.