[llvm] [StructurizeCFG] Hoist and simplify zero-cost incoming else phi values (PR #139605)
Vigneshwar Jayakumar via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 2 06:41:20 PDT 2025
================
@@ -403,6 +416,35 @@ class StructurizeCFGLegacyPass : public RegionPass {
} // end anonymous namespace
+/// Checks whether an instruction is zero cost instruction and checks if the
+/// operands are from different BB. If so, this instruction can be coalesced
+/// if its hoisted to predecessor block. So, this returns true.
+static bool isHoistableInstruction(Instruction *I, BasicBlock *BB,
+ TargetTransformInfo *TTI) {
+
+ if (I->getParent() != BB)
+ return false;
+
+ // If the instruction is not a zero cost instruction, return false.
+ auto Cost = TTI->getInstructionCost(I, TargetTransformInfo::TCK_CodeSize);
----------------
VigneshwarJ wrote:
As we are looking for instructions that are just cross-block zero cost copies, I thought Latency or recipThroughput did not matter. But if I am wrong in my understanding, I can change the metric.
https://github.com/llvm/llvm-project/pull/139605
More information about the llvm-commits
mailing list