llvm-project/llvm/lib/CodeGen/SelectionDAG
Nicolai Haehnle a9cc92c247 AMDGPU: Fix various issues around the VirtReg2Value mapping
Summary:
The VirtReg2Value mapping is crucial for getting consistently
reliable divergence information into the SelectionDAG. This
patch fixes a bunch of issues that lead to incorrect divergence
info and introduces tight assertions to ensure we don't regress:

1. VirtReg2Value is generated lazily; there were some cases where
   a lookup was performed before all relevant virtual registers were
   created, leading to an out-of-sync mapping. Those cases were:

  - Complex code to lower formal arguments that generated CopyFromReg
    nodes from live-in registers (fixed by never querying the mapping
    for live-in registers).

  - Code that generates CopyToReg for formal arguments that are used
    outside the entry basic block (fixed by never querying the
    mapping for Register nodes, which don't need the divergence info
    anyway).

2. For complex values that are lowered to a sequence of registers,
   all registers must be reflected in the VirtReg2Value mapping.

I am not adding any new tests, since I'm not actually aware of any
bugs that these problems are causing with trunk as-is. However,
I recently added a test case (in r346423) which fails when D53283 is
applied without this change. Also, the new assertions should provide
most of the effective test coverage.

There is one test change in sdwa-peephole.ll. The underlying issue
is that since the divergence info is now correct, the DAGISel will
select V_OR_B32 directly instead of S_OR_B32. This leads to an extra
COPY which affects the behavior of MachineLICM in a way that ends up
with the S_MOV_B32 with the constant in a different basic block than
the V_OR_B32, which is presumably what defeats the peephole.

Reviewers: alex-t, arsenm, rampitec

Subscribers: kzhuravl, jvesely, wdng, yaxunl, dstuttard, tpr, t-tye, llvm-commits

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

llvm-svn: 348049
2018-11-30 22:55:29 +00:00
..
CMakeLists.txt Remove trailing whitespace to trigger re-cmaking 2017-10-02 21:54:38 +00:00
DAGCombiner.cpp [DAGCombiner] narrow truncated binops 2018-11-29 20:58:26 +00:00
FastISel.cpp Add support for llvm.is.constant intrinsic (PR4898) 2018-11-07 15:24:12 +00:00
FunctionLoweringInfo.cpp AMDGPU: Fix various issues around the VirtReg2Value mapping 2018-11-30 22:55:29 +00:00
InstrEmitter.cpp [ARM] Make InstrEmitter mark CPSR defs dead for Thumb1. 2018-10-26 19:32:24 +00:00
InstrEmitter.h [DebugInfo] Convert intrinsic llvm.dbg.label to MachineInstr. 2018-05-09 02:41:08 +00:00
LLVMBuild.txt
LegalizeDAG.cpp [FPEnv] Add constrained CEIL/FLOOR/ROUND/TRUNC intrinsics 2018-11-05 15:59:49 +00:00
LegalizeFloatTypes.cpp [NFC] Rename minnan and maxnan to minimum and maximum 2018-10-24 22:49:55 +00:00
LegalizeIntegerTypes.cpp [SelectionDAG] Support result type promotion for FLT_ROUNDS_ 2018-11-30 13:18:33 +00:00
LegalizeTypes.cpp [DAG] Don't map a TableId to itself in the ReplacedValues map 2018-06-20 16:06:09 +00:00
LegalizeTypes.h [SelectionDAG] Support result type promotion for FLT_ROUNDS_ 2018-11-30 13:18:33 +00:00
LegalizeTypesGeneric.cpp [LegalizeTypes] Fix bad indentation. NFC 2018-09-23 21:17:55 +00:00
LegalizeVectorOps.cpp [SelectionDAG][AArch64][X86] Move legalization of vector MULHS/MULHU from LegalizeDAG to LegalizeVectorOps 2018-11-29 19:36:17 +00:00
LegalizeVectorTypes.cpp [LegalizeVectorTypes][X86][ARM][AArch64][PowerPC] Don't use SplitVecOp_TruncateHelper for FP_TO_SINT/UINT. 2018-11-26 21:12:39 +00:00
ResourcePriorityQueue.cpp Silence a bunch of implicit fallthrough warnings 2017-12-19 22:05:25 +00:00
SDNodeDbgValue.h SelectionDAG: Add compact SDDbgValue representation to -dag-dump-verbose output 2018-09-14 17:08:02 +00:00
ScheduleDAGFast.cpp ScheduleDAG: Cleanup dumping code; NFC 2018-09-19 00:23:35 +00:00
ScheduleDAGRRList.cpp ScheduleDAG: Cleanup dumping code; NFC 2018-09-19 00:23:35 +00:00
ScheduleDAGSDNodes.cpp llvm::sort(C.begin(), C.end(), ...) -> llvm::sort(C, ...) 2018-09-27 02:13:45 +00:00
ScheduleDAGSDNodes.h ScheduleDAG: Cleanup dumping code; NFC 2018-09-19 00:23:35 +00:00
ScheduleDAGVLIW.cpp ScheduleDAG: Cleanup dumping code; NFC 2018-09-19 00:23:35 +00:00
SelectionDAG.cpp [SelectionDAG] fold FP binops with 2 undef operands to undef 2018-11-30 18:38:52 +00:00
SelectionDAGAddressAnalysis.cpp [SelectionDAG] Teach BaseIndexOffset::match to unwrap the base after looking through an add/or 2018-11-26 20:16:33 +00:00
SelectionDAGBuilder.cpp [SelectionDAG] Compute known bits and num sign bits for live out vector registers. Use it to add AssertZExt/AssertSExt in the live in basic blocks 2018-11-20 04:30:26 +00:00
SelectionDAGBuilder.h [IR] Add a dedicated FNeg IR Instruction 2018-11-13 18:15:47 +00:00
SelectionDAGDumper.cpp [FPEnv] Add constrained CEIL/FLOOR/ROUND/TRUNC intrinsics 2018-11-05 15:59:49 +00:00
SelectionDAGISel.cpp TableGen/ISel: Allow PatFrag predicate code to access captured operands 2018-11-30 14:15:13 +00:00
SelectionDAGPrinter.cpp Rename DEBUG macro to LLVM_DEBUG. 2018-05-14 12:53:11 +00:00
SelectionDAGTargetInfo.cpp [CodeGen] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC). 2017-09-13 21:15:20 +00:00
StatepointLowering.cpp [CodeGen] Prefer static frame index for STATEPOINT liveness args 2018-11-30 16:22:41 +00:00
StatepointLowering.h [IR][CodeGen] Remove dependency on EVT from IR/Function.cpp. Move EVT to CodeGen layer. 2018-03-29 17:21:10 +00:00
TargetLowering.cpp [TargetLowering] SimplifyDemandedBits - only reduce known bits for integer constants 2018-11-21 14:26:19 +00:00