[llvm] r304696 - [AMDGPU] Fix SIFoldOperands crash with clamp
Stanislav Mekhanoshin via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 4 18:03:06 PDT 2017
Author: rampitec
Date: Sun Jun 4 20:03:04 2017
New Revision: 304696
URL: http://llvm.org/viewvc/llvm-project?rev=304696&view=rev
Log:
[AMDGPU] Fix SIFoldOperands crash with clamp
Fixes bug #33302. Pass did not account that Src1 of max instruction
can be an immediate.
Differential Revision: https://reviews.llvm.org/D33884
Modified:
llvm/trunk/lib/Target/AMDGPU/SIFoldOperands.cpp
llvm/trunk/test/CodeGen/AMDGPU/clamp-omod-special-case.mir
Modified: llvm/trunk/lib/Target/AMDGPU/SIFoldOperands.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/SIFoldOperands.cpp?rev=304696&r1=304695&r2=304696&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/SIFoldOperands.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/SIFoldOperands.cpp Sun Jun 4 20:03:04 2017
@@ -730,7 +730,8 @@ const MachineOperand *SIFoldOperands::is
// Make sure sources are identical.
const MachineOperand *Src0 = TII->getNamedOperand(MI, AMDGPU::OpName::src0);
const MachineOperand *Src1 = TII->getNamedOperand(MI, AMDGPU::OpName::src1);
- if (!Src0->isReg() || Src0->getSubReg() != Src1->getSubReg() ||
+ if (!Src0->isReg() || !Src1->isReg() ||
+ Src0->getSubReg() != Src1->getSubReg() ||
Src0->getSubReg() != AMDGPU::NoSubRegister)
return nullptr;
Modified: llvm/trunk/test/CodeGen/AMDGPU/clamp-omod-special-case.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AMDGPU/clamp-omod-special-case.mir?rev=304696&r1=304695&r2=304696&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/clamp-omod-special-case.mir (original)
+++ llvm/trunk/test/CodeGen/AMDGPU/clamp-omod-special-case.mir Sun Jun 4 20:03:04 2017
@@ -24,6 +24,10 @@
ret void
}
+ define amdgpu_ps void @v_max_reg_imm_f32() #0 {
+ ret void
+ }
+
attributes #0 = { nounwind "no-signed-zeros-fp-math"="false" }
...
@@ -422,3 +426,19 @@ body: |
S_ENDPGM
...
+---
+
+# Pass used to crash with immediate second operand of max
+name: v_max_reg_imm_f32
+tracksRegLiveness: true
+registers:
+ - { id: 0, class: vgpr_32 }
+ - { id: 1, class: vgpr_32 }
+body: |
+ bb.0 (%ir-block.0):
+ liveins: %vgpr0
+
+ %0 = COPY %vgpr0
+ %1 = V_MAX_F32_e64 0, killed %0, 0, 1056964608, 1, 0, implicit %exec
+
+...
More information about the llvm-commits
mailing list