R600/SI: Wrap local memory pointer in AssertZExt on SI
authorTom Stellard <thomas.stellard@amd.com>
Fri, 22 Aug 2014 18:49:31 +0000 (18:49 +0000)
committerTom Stellard <thomas.stellard@amd.com>
Fri, 22 Aug 2014 18:49:31 +0000 (18:49 +0000)
These pointers are really just offsets and they will always be
less than 16-bits.  Using AssertZExt allows us to use computeKnownBits
to prove that these values are positive.  We will use this information
in a later commit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216277 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/R600/SIISelLowering.cpp

index ec259f11feb402009880718d9e899c9a4ef1dc9a..67f566f019d2e62af8735bb674feb18f97d45d80 100644 (file)
@@ -504,6 +504,18 @@ SDValue SITargetLowering::LowerFormalArguments(
       SDValue Arg = LowerParameter(DAG, VT, MemVT,  DL, DAG.getRoot(),
                                    36 + VA.getLocMemOffset(),
                                    Ins[i].Flags.isSExt());
+
+      const PointerType *ParamTy =
+          dyn_cast<PointerType>(FType->getParamType(Ins[i].OrigArgIndex));
+      if (Subtarget->getGeneration() == AMDGPUSubtarget::SOUTHERN_ISLANDS &&
+          ParamTy && ParamTy->getAddressSpace() == AMDGPUAS::LOCAL_ADDRESS) {
+        // On SI local pointers are just offsets into LDS, so they are always
+        // less than 16-bits.  On CI and newer they could potentially be
+        // real pointers, so we can't guarantee their size.
+        Arg = DAG.getNode(ISD::AssertZext, DL, Arg.getValueType(), Arg,
+                          DAG.getValueType(MVT::i16));
+      }
+
       InVals.push_back(Arg);
       continue;
     }