[llvm] r327209 - AMDGPU: Fix crash when constant folding with physreg operand
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 10 08:05:35 PST 2018
Author: arsenm
Date: Sat Mar 10 08:05:35 2018
New Revision: 327209
URL: http://llvm.org/viewvc/llvm-project?rev=327209&view=rev
Log:
AMDGPU: Fix crash when constant folding with physreg operand
Modified:
llvm/trunk/lib/Target/AMDGPU/SIFoldOperands.cpp
llvm/trunk/test/CodeGen/AMDGPU/constant-fold-imm-immreg.mir
Modified: llvm/trunk/lib/Target/AMDGPU/SIFoldOperands.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/SIFoldOperands.cpp?rev=327209&r1=327208&r2=327209&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/SIFoldOperands.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/SIFoldOperands.cpp Sat Mar 10 08:05:35 2018
@@ -471,7 +471,8 @@ static MachineOperand *getImmOrMateriali
MachineOperand &Op) {
if (Op.isReg()) {
// If this has a subregister, it obviously is a register source.
- if (Op.getSubReg() != AMDGPU::NoSubRegister)
+ if (Op.getSubReg() != AMDGPU::NoSubRegister ||
+ !TargetRegisterInfo::isVirtualRegister(Op.getReg()))
return &Op;
MachineInstr *Def = MRI.getVRegDef(Op.getReg());
Modified: llvm/trunk/test/CodeGen/AMDGPU/constant-fold-imm-immreg.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AMDGPU/constant-fold-imm-immreg.mir?rev=327209&r1=327208&r2=327209&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/constant-fold-imm-immreg.mir (original)
+++ llvm/trunk/test/CodeGen/AMDGPU/constant-fold-imm-immreg.mir Sat Mar 10 08:05:35 2018
@@ -804,3 +804,30 @@ body: |
S_ENDPGM
...
+---
+# Make sure there is no crash if one of the operands is a physical register
+# GCN-LABEL: name: constant_fold_physreg_op{{$}}
+# GCN: %3:sreg_64 = S_AND_B64 $exec, 0, implicit-def dead $scc
+
+name: constant_fold_physreg_op
+tracksRegLiveness: true
+body: |
+ bb.0:
+ successors: %bb.1, %bb.3
+ liveins: $vgpr0, $sgpr4_sgpr5
+
+ %19:sreg_64 = IMPLICIT_DEF
+ %0:sreg_64 = SI_IF killed %19, %bb.3, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
+ S_BRANCH %bb.1
+
+ bb.1:
+ %6:sreg_64 = S_MOV_B64 0
+ %7:sreg_64 = S_AND_B64 $exec, killed %6, implicit-def dead $scc
+ $vcc = COPY %7
+
+ bb.3:
+ liveins: $vcc
+ SI_END_CF %0, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
+ S_ENDPGM implicit $vcc
+
+...
More information about the llvm-commits
mailing list