Skip to content

Commit c442538

Browse files
committed
review
1 parent 0e13ed3 commit c442538

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

llvm/lib/Transforms/Scalar/StructurizeCFG.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ static bool isHoistableInstruction(Instruction *I, BasicBlock *BB,
426426
return false;
427427

428428
// If the instruction is not a zero cost instruction, return false.
429-
auto Cost = TTI->getInstructionCost(I, TargetTransformInfo::TCK_CodeSize);
429+
auto Cost = TTI->getInstructionCost(I, TargetTransformInfo::TCK_Latency);
430430
InstructionCost::CostType CostVal =
431431
Cost.isValid()
432432
? Cost.getValue()
@@ -435,8 +435,8 @@ static bool isHoistableInstruction(Instruction *I, BasicBlock *BB,
435435
return false;
436436

437437
// Check if any operands are instructions defined in the same block.
438-
for (unsigned i = 0, e = I->getNumOperands(); i < e; ++i) {
439-
if (auto *OpI = dyn_cast<Instruction>(I->getOperand(i))) {
438+
for (auto &Op : I->operands()) {
439+
if (auto *OpI = dyn_cast<Instruction>(Op)) {
440440
if (OpI->getParent() == BB)
441441
return false;
442442
}
@@ -976,7 +976,9 @@ void StructurizeCFG::simplifyHoistedPhis() {
976976

977977
for (int i = 0; i < 2; i++) {
978978
Value *V = Phi->getIncomingValue(i);
979-
if (!HoistedValues.count(V))
979+
auto BBIt = HoistedValues.find(V);
980+
981+
if (BBIt == HoistedValues.end())
980982
continue;
981983

982984
Value *OtherV = Phi->getIncomingValue(!i);
@@ -992,7 +994,7 @@ void StructurizeCFG::simplifyHoistedPhis() {
992994
break;
993995
}
994996
if (PoisonValBBIdx == -1 ||
995-
!DT->dominates(HoistedValues[V],
997+
!DT->dominates(BBIt->second,
996998
OtherPhi->getIncomingBlock(PoisonValBBIdx)))
997999
continue;
9981000

llvm/test/CodeGen/AMDGPU/structurize-hoist.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2-
; RUN: llc -mtriple=amdgcn -mcpu=gfx900 -verify-machineinstrs < %s | FileCheck -check-prefix=GFX900 %s
2+
; RUN: llc -mtriple=amdgcn -mcpu=gfx900 < %s | FileCheck -check-prefix=GFX900 %s
33

44

55
%pair = type { i32, i32 }

llvm/test/Transforms/StructurizeCFG/hoist-zerocost.ll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2-
; RUN: opt -S -passes=structurizecfg %s -o - | FileCheck %s
3-
2+
; RUN: opt -S -passes=structurizecfg < %s | FileCheck %s
43

54

65
%pair = type { i32, i32 }

0 commit comments

Comments
 (0)