[llvm] [StructurizeCFG] Hoist and simplify zero-cost incoming else phi values (PR #139605)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 2 06:45:33 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);
----------------
arsenm wrote:

The AMDGPU cost model has seen close to 0 effort on getting accurate code sizes. You'll probably get better results for the default latency 

https://github.com/llvm/llvm-project/pull/139605


More information about the llvm-commits mailing list