[llvm] [CodeGen] Avoid sinking vector comparisons during CodeGenPrepare (PR #113158)

via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 21 07:20:31 PDT 2024


================
@@ -1779,29 +1779,35 @@ static bool sinkCmpExpression(CmpInst *Cmp, const TargetLowering &TLI) {
   if (TLI.useSoftFloat() && isa<FCmpInst>(Cmp))
     return false;
 
-  // Only insert a cmp in each block once.
-  DenseMap<BasicBlock *, CmpInst *> InsertedCmps;
+  // Collect a list of non-phis users that are in blocks that are different to
+  // the definition block.
+  BasicBlock *DefBB = Cmp->getParent();
+  SmallSet<User *, 4> Users;
+  for (auto *U : Cmp->users()) {
+    Instruction *User = cast<Instruction>(U);
+    if (isa<PHINode>(User))
----------------
goldsteinn wrote:

Maybe keep some full-user iteration below and also skip pseudo instructions that will be dropped during codegen here?

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


More information about the llvm-commits mailing list