diff options
| author | Matt Arsenault <Matthew.Arsenault@amd.com> | 2017-11-30 00:52:40 +0000 |
|---|---|---|
| committer | Matt Arsenault <Matthew.Arsenault@amd.com> | 2017-11-30 00:52:40 +0000 |
| commit | caf0ed4d74e8a3f1b05ddec05dffee3b795a72a3 (patch) | |
| tree | 46750e826e58bf5dd10bde6e58c864172daef12b /llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp | |
| parent | a4e418f71342da5ad67e211557971a40b13db9e8 (diff) | |
| download | bcm5719-llvm-caf0ed4d74e8a3f1b05ddec05dffee3b795a72a3.tar.gz bcm5719-llvm-caf0ed4d74e8a3f1b05ddec05dffee3b795a72a3.zip | |
AMDGPU: Allow negative MUBUF vaddr for gfx9
GFX9 does not enable bounds checking for the resource descriptors
used for private access, so it should be OK to use vaddr with
a potentially negative value.
llvm-svn: 319393
Diffstat (limited to 'llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp')
| -rw-r--r-- | llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp b/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp index 836c70609c0..79d8de92031 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp @@ -1158,14 +1158,25 @@ bool AMDGPUDAGToDAGISel::SelectMUBUFScratchOffen(SDNode *Parent, SDValue N0 = Addr.getOperand(0); SDValue N1 = Addr.getOperand(1); - // Offsets in vaddr must be positive. + // Offsets in vaddr must be positive if range checking is enabled. // - // The total computation of vaddr + soffset + offset must not overflow. - // If vaddr is negative, even if offset is 0 the sgpr offset add will end up + // The total computation of vaddr + soffset + offset must not overflow. If + // vaddr is negative, even if offset is 0 the sgpr offset add will end up // overflowing. + // + // Prior to gfx9, MUBUF instructions with the vaddr offset enabled would + // always perform a range check. If a negative vaddr base index was used, + // this would fail the range check. The overall address computation would + // compute a valid address, but this doesn't happen due to the range + // check. For out-of-bounds MUBUF loads, a 0 is returned. + // + // Therefore it should be safe to fold any VGPR offset on gfx9 into the + // MUBUF vaddr, but not on older subtargets which can only do this if the + // sign bit is known 0. ConstantSDNode *C1 = cast<ConstantSDNode>(N1); if (SIInstrInfo::isLegalMUBUFImmOffset(C1->getZExtValue()) && - CurDAG->SignBitIsZero(N0)) { + (!Subtarget->privateMemoryResourceIsRangeChecked() || + CurDAG->SignBitIsZero(N0))) { std::tie(VAddr, SOffset) = foldFrameIndex(N0); ImmOffset = CurDAG->getTargetConstant(C1->getZExtValue(), DL, MVT::i16); return true; |

