[PATCH] D140190: [InstCombine] Preserve Instruction name when converting select to max/min/abs.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 15 22:55:11 PST 2022


craig.topper created this revision.
craig.topper added reviewers: spatel, RKSimon, lebedev.ri.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added a project: LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140190

Files:
  llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp


Index: llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
===================================================================
--- llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -1141,6 +1141,7 @@
 
     if (SPF == SelectPatternFlavor::SPF_NABS)
       return BinaryOperator::CreateNeg(Abs); // Always without NSW flag!
+    Abs->takeName(&Sel);
     return IC.replaceInstUsesWith(Sel, Abs);
   }
 
@@ -1162,8 +1163,9 @@
     default:
       llvm_unreachable("Unexpected SPF");
     }
-    return IC.replaceInstUsesWith(
-        Sel, IC.Builder.CreateBinaryIntrinsic(IntrinsicID, LHS, RHS));
+    Instruction *MinMax = IC.Builder.CreateBinaryIntrinsic(IntrinsicID, LHS, RHS);
+    MinMax->takeName(&Sel);
+    return IC.replaceInstUsesWith(Sel, MinMax);
   }
 
   return nullptr;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140190.483437.patch
Type: text/x-patch
Size: 851 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221216/a21fde78/attachment.bin>


More information about the llvm-commits mailing list