[llvm] e585b33 - [AMDGPU] PHI node cost should not be counted for the size and latency.
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 30 06:11:33 PDT 2021
Author: alex-t
Date: 2021-06-30T16:11:17+03:00
New Revision: e585b332e42321870b2cf1eeefcd68b0717570e2
URL: https://github.com/llvm/llvm-project/commit/e585b332e42321870b2cf1eeefcd68b0717570e2
DIFF: https://github.com/llvm/llvm-project/commit/e585b332e42321870b2cf1eeefcd68b0717570e2.diff
LOG: [AMDGPU] PHI node cost should not be counted for the size and latency.
Details: https://reviews.llvm.org/D96805 changed the GCNTTIImpl::getCFInstrCost to return 1 for the PHI nodes
for the TTI::TCK_CodeSize and TTI::TCK_SizeAndLatency. This is incorrect because the value moves that are the
result of the PHI lowering are inserted into the basic block predecessors - not into the block itself.
As a result of this change LoopRotate and LoopUnroll were broken because of the incorrect Loop header and loop
body size/cost estimation.
Reviewed By: rampitec
Differential Revision: https://reviews.llvm.org/D105104
Added:
Modified:
llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
llvm/test/Analysis/CostModel/AMDGPU/control-flow.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp b/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
index fe138fd7bf326..67886b9681aeb 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
@@ -837,10 +837,6 @@ InstructionCost GCNTTIImpl::getCFInstrCost(unsigned Opcode,
}
case Instruction::Ret:
return SCost ? 1 : 10;
- case Instruction::PHI:
- // TODO: 1. A prediction phi won't be eliminated?
- // 2. Estimate data copy instructions in this case.
- return 1;
}
return BaseT::getCFInstrCost(Opcode, CostKind, I);
}
diff --git a/llvm/test/Analysis/CostModel/AMDGPU/control-flow.ll b/llvm/test/Analysis/CostModel/AMDGPU/control-flow.ll
index ef469ccb48278..88c4956f3fc0e 100644
--- a/llvm/test/Analysis/CostModel/AMDGPU/control-flow.ll
+++ b/llvm/test/Analysis/CostModel/AMDGPU/control-flow.ll
@@ -8,7 +8,7 @@
; SPEED: estimated cost of 10 for instruction: ret void
; SIZE: estimated cost of 5 for instruction: br i1
; SIZE: estimated cost of 1 for instruction: br label
-; SIZE: estimated cost of 1 for instruction: %phi = phi i32 [
+; SIZE: estimated cost of 0 for instruction: %phi = phi i32 [
; SIZE: estimated cost of 1 for instruction: ret void
define amdgpu_kernel void @test_br_cost(i32 addrspace(1)* %out, i32 addrspace(1)* %vaddr, i32 %b) #0 {
bb0:
More information about the llvm-commits
mailing list