]> granicus.if.org Git - llvm/commitdiff
[AMDGPU] Handle undef old operand in DPP combine
authorStanislav Mekhanoshin <Stanislav.Mekhanoshin@amd.com>
Thu, 10 Oct 2019 21:32:41 +0000 (21:32 +0000)
committerStanislav Mekhanoshin <Stanislav.Mekhanoshin@amd.com>
Thu, 10 Oct 2019 21:32:41 +0000 (21:32 +0000)
It was missing an undef flag.

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

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

lib/Target/AMDGPU/GCNDPPCombine.cpp
test/CodeGen/AMDGPU/dpp_combine.mir

index 954058592d659b7d2fd990c5a2df0ce1b2363c4a..f788ea6826ea3bec8501d14dbf60796bcdbdc8a5 100644 (file)
@@ -178,7 +178,9 @@ MachineInstr *GCNDPPCombine::createDPPInst(MachineInstr &OrigMI,
     if (OldIdx != -1) {
       assert(OldIdx == NumOperands);
       assert(isOfRegClass(CombOldVGPR, AMDGPU::VGPR_32RegClass, *MRI));
-      DPPInst.addReg(CombOldVGPR.Reg, 0, CombOldVGPR.SubReg);
+      auto *Def = getVRegSubRegDef(CombOldVGPR, *MRI);
+      DPPInst.addReg(CombOldVGPR.Reg, Def ? 0 : RegState::Undef,
+                     CombOldVGPR.SubReg);
       ++NumOperands;
     } else {
       // TODO: this discards MAC/FMA instructions for now, let's add it later
index 9c3841cba11a74927772aca2fcdc306d583d8b6f..af08c9added6dedca4bb7686259cec6dea1caa43 100644 (file)
@@ -512,7 +512,7 @@ body: |
 ...
 
 # CHECK-LABEL: name: add_old_subreg_undef
-# CHECK: %5:vgpr_32 = V_ADD_U32_dpp %3.sub1, %1, %0.sub1, 1, 15, 15, 1, implicit $exec
+# CHECK: %5:vgpr_32 = V_ADD_U32_dpp undef %3.sub1, %1, %0.sub1, 1, 15, 15, 1, implicit $exec
 
 name:            add_old_subreg_undef
 tracksRegLiveness: true
@@ -551,3 +551,14 @@ body: |
     %2:vgpr_32 = V_MOV_B32_dpp %1:vgpr_32, undef %0:vgpr_32, 1, 15, 15, 1, implicit $exec
     %4:vgpr_32 = V_MIN_F32_e32 %2, undef %3:vgpr_32, implicit $exec
 ...
+
+# Test an undef old operand
+# CHECK-LABEL: name: dpp_undef_old
+# CHECK: %3:vgpr_32 = V_CEIL_F32_dpp undef %1:vgpr_32, 0, undef %2:vgpr_32, 1, 15, 15, 1, implicit $exec
+name: dpp_undef_old
+tracksRegLiveness: true
+body: |
+  bb.0:
+    %2:vgpr_32 = V_MOV_B32_dpp undef %1:vgpr_32, undef %0:vgpr_32, 1, 15, 15, 1, implicit $exec
+    %3:vgpr_32 = V_CEIL_F32_e32 %2, implicit $exec
+...