llvm-project/llvm/test
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
..
Analysis [AMDGPU] Switch to the new addr space mapping by default 2018-02-02 16:07:16 +00:00
Assembler Revert "[DebugInfo] Improvements to representation of enumeration types (PR36168)" 2018-02-07 20:28:47 +00:00
Bindings [LLVM-C] Add Accessors For A Module's Source File Name 2018-01-30 21:34:29 +00:00
Bitcode [ThinLTO] Serialize WithGlobalValueDeadStripping index flag for distributed backends 2018-02-07 04:05:59 +00:00
BugPoint
CodeGen [X86] Don't emit KTEST instructions unless only the Z flag is being used 2018-02-08 07:45:55 +00:00
DebugInfo Revert "[DebugInfo] Improvements to representation of enumeration types (PR36168)" 2018-02-07 20:28:47 +00:00
Examples
ExecutionEngine Don't try to run MCJIT/OrcJIT EH tests when C++ library is statically linked 2018-01-08 02:48:41 +00:00
Feature Mark two tests REQUIRES: x86-registered-backend 2018-01-31 07:32:03 +00:00
FileCheck [FileCheck] - Fix possible buffer out of bounds access when parsing --check-prefix. 2018-01-16 08:09:24 +00:00
Instrumentation [InstrProfiling] Don't exit early when an unused intrinsic is found 2018-01-27 00:01:04 +00:00
Integer
JitListener
LTO LTO: Also include dso-local bit for calls in ThinLTO cache key. 2018-02-05 23:46:32 +00:00
Linker [DWARF] Regularize dumping strings from line tables. 2018-02-05 20:43:15 +00:00
MC [DWARFv5] Emit .debug_line_str (in a non-DWO file). 2018-02-06 20:29:21 +00:00
Object Remove alignment argument from memcpy/memmove/memset in favour of alignment attributes (Step 1) 2018-01-19 17:13:12 +00:00
ObjectYAML [WebAssembly] Remove debug names from symbol table 2018-01-17 19:28:43 +00:00
Other Re-commit : [PowerPC] Add handling for ColdCC calling convention and a pass to mark 2018-01-30 16:17:22 +00:00
SafepointIRVerifier
SymbolRewriter
TableGen [TableGen] Make sure !if is evaluated throughout class inheritance. 2018-01-30 19:29:21 +00:00
ThinLTO/X86 [ThinLTO] Remove dead and dropped symbol declarations when possible 2018-02-06 00:43:39 +00:00
Transforms [SimplifyCFG] Re-apply Relax restriction for folding unconditional branches 2018-02-08 07:16:29 +00:00
Unit
Verifier Add DWARF for discriminated unions 2018-02-06 23:45:59 +00:00
YAMLParser
tools Revert dsymutil -update commits 2018-02-07 17:35:27 +00:00
.clang-format
CMakeLists.txt
TestRunner.sh
lit.cfg.py Don't try to run MCJIT/OrcJIT EH tests when C++ library is statically linked 2018-01-08 02:48:41 +00:00
lit.site.cfg.py.in