llvm/lib
Hal Finkel 8d0ebe9402 [DAGCombine] More fixups to SETCC legality checking (visitANDLike/visitORLike)
I might have called this "r246507, the sequel". It fixes the same issue, as the
issue has cropped up in a few more places. The underlying problem is that
isSetCCEquivalent can pick up select_cc nodes with a result type that is not
legal for a setcc node to have, and if we use that type to create new setcc
nodes, nothing fixes that (and so we've violated the contract that the
infrastructure has with the backend regarding setcc node types).

Fixes PR30276.

For convenience, here's the commit message from r246507, which explains the
problem is greater detail:

[DAGCombine] Fixup SETCC legality checking

SETCC is one of those special node types for which operation actions (legality,
etc.) is keyed off of an operand type, not the node's value type. This makes
sense because the value type of a legal SETCC node is determined by its
operands' value type (via the TLI function getSetCCResultType). When the
SDAGBuilder creates SETCC nodes, it either creates them with an MVT::i1 value
type, or directly with the value type provided by TLI.getSetCCResultType.

The first problem being fixed here is that DAGCombine had several places
querying TLI.isOperationLegal on SETCC, but providing the return of
getSetCCResultType, instead of the operand type directly. This does not mean
what the author thought, and "luckily", most in-tree targets have SETCC with
Custom lowering, instead of marking them Legal, so these checks return false
anyway.

The second problem being fixed here is that two of the DAGCombines could create
SETCC nodes with arbitrary (integer) value types; specifically, those that
would simplify:

  (setcc a, b, op1) and|or (setcc a, b, op2) -> setcc a, b, op3
     (which is possible for some combinations of (op1, op2))

If the operands of the and|or node are actual setcc nodes, then this is not an
issue (because the and|or must share the same type), but, the relevant code in
DAGCombiner::visitANDLike and DAGCombiner::visitORLike actually calls
DAGCombiner::isSetCCEquivalent on each operand, and that function will
recognise setcc-like select_cc nodes with other return types. And, thus, when
creating new SETCC nodes, we need to be careful to respect the value-type
constraint. This is even true before type legalization, because it is quite
possible for the SELECT_CC node to have a legal type that does not happen to
match the corresponding TLI.getSetCCResultType type.

To be explicit, there is nothing that later fixes the value types of SETCC
nodes (if the type is legal, but does not happen to match
TLI.getSetCCResultType). Creating SETCCs with an MVT::i1 value type seems to
work only because, either MVT::i1 is not legal, or it is what
TLI.getSetCCResultType returns if it is legal. Fixing that is a larger change,
however. For the time being, restrict the relevant transformations to produce
only SETCC nodes with a value type matching TLI.getSetCCResultType (or MVT::i1
prior to type legalization).

Fixes PR24636.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@280767 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-06 23:02:23 +00:00
..
Analysis [LCG] Clean up and make NDEBUG verify calls more rigorous with 2016-09-04 08:34:31 +00:00
AsmParser DebugInfo: use strongly typed enum for debug info flags 2016-09-06 10:46:28 +00:00
Bitcode Formatting with clang-format patch r280700 2016-09-06 17:03:02 +00:00
CodeGen [DAGCombine] More fixups to SETCC legality checking (visitANDLike/visitORLike) 2016-09-06 23:02:23 +00:00
DebugInfo [codeview] Use the correct max CV record length of 0xFF00 2016-09-02 18:43:27 +00:00
Demangle Avoid using alignas and constexpr. 2016-09-06 20:36:24 +00:00
ExecutionEngine [ORC] Clone module flags metadata into the globals module in the 2016-09-04 17:53:30 +00:00
Fuzzer [libFuzzer] add -minimize_crash flag (to minimize crashers). also add two tests that I failed to commit last time 2016-09-01 01:22:27 +00:00
IR Formatting with clang-format patch r280700 2016-09-06 17:03:02 +00:00
IRReader Remove autoconf support 2016-01-26 21:29:08 +00:00
LibDriver Object: Replace NewArchiveIterator with a simpler NewArchiveMember class. NFCI. 2016-06-29 22:27:42 +00:00
LineEditor Fix Clang-tidy modernize-deprecated-headers warnings in some files; other minor fixes. 2016-03-28 17:40:08 +00:00
Linker Fix ThinLTO crash with debug info 2016-09-03 21:12:33 +00:00
LTO [LTO] Constify (NFC) 2016-09-06 03:23:45 +00:00
MC (LLVM part) Implement MASM-flavor intel syntax behavior for inline MS asm block: 2016-09-02 23:15:29 +00:00
Object Next set of additional error checks for invalid Mach-O files for bad load commands 2016-08-31 17:57:46 +00:00
ObjectYAML [macho2yaml] Don't write empty linkedit data 2016-08-17 21:46:04 +00:00
Option Replace "fallthrough" comments with LLVM_FALLTHROUGH 2016-08-17 05:10:15 +00:00
Passes [EarlyCSE] Optionally use MemorySSA. NFC. 2016-08-31 19:24:10 +00:00
ProfileData [Coverage] Make sorting criteria for CounterMappingRegions local. 2016-08-31 07:01:17 +00:00
Support Add an c++ itanium demangler to llvm. 2016-09-06 19:16:48 +00:00
TableGen Fix some Clang-tidy modernize-use-using and Include What You Use warnings; other minor fixes. 2016-08-23 17:14:32 +00:00
Target [AMDGPU] Wave and register controls 2016-09-06 20:22:28 +00:00
Transforms Explicitly require DominatorTreeAnalysis pass for instsimplify pass. 2016-09-06 22:17:16 +00:00
CMakeLists.txt Try to fix a circular dependency in the modules build. 2016-09-06 20:16:19 +00:00
LLVMBuild.txt Add an c++ itanium demangler to llvm. 2016-09-06 19:16:48 +00:00