OSDN Git Service

[AMDGPU] gfx1010 verifier changes
authorStanislav Mekhanoshin <Stanislav.Mekhanoshin@amd.com>
Mon, 6 May 2019 22:49:45 +0000 (22:49 +0000)
committerStanislav Mekhanoshin <Stanislav.Mekhanoshin@amd.com>
Mon, 6 May 2019 22:49:45 +0000 (22:49 +0000)
Differential Revision: https://reviews.llvm.org/D61521

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

lib/Target/AMDGPU/SIInstrInfo.cpp

index ffdc75c..8f4a073 100644 (file)
@@ -3192,16 +3192,24 @@ bool SIInstrInfo::verifyInstruction(const MachineInstr &MI,
   }
 
   if (isSOPK(MI)) {
-    int64_t Imm = getNamedOperand(MI, AMDGPU::OpName::simm16)->getImm();
-    if (sopkIsZext(MI)) {
-      if (!isUInt<16>(Imm)) {
-        ErrInfo = "invalid immediate for SOPK instruction";
+    auto Op = getNamedOperand(MI, AMDGPU::OpName::simm16);
+    if (Desc.isBranch()) {
+      if (!Op->isMBB()) {
+        ErrInfo = "invalid branch target for SOPK instruction";
         return false;
       }
     } else {
-      if (!isInt<16>(Imm)) {
-        ErrInfo = "invalid immediate for SOPK instruction";
-        return false;
+      uint64_t Imm = Op->getImm();
+      if (sopkIsZext(MI)) {
+        if (!isUInt<16>(Imm)) {
+          ErrInfo = "invalid immediate for SOPK instruction";
+          return false;
+        }
+      } else {
+        if (!isInt<16>(Imm)) {
+          ErrInfo = "invalid immediate for SOPK instruction";
+          return false;
+        }
       }
     }
   }