[llvm] 86d1ed9 - [InlineCost] Avoid ConstantExpr::getSelect()

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 27 07:47:25 PST 2023


Author: Nikita Popov
Date: 2023-02-27T16:47:16+01:00
New Revision: 86d1ed9e480849ff57dfee23975165465ebe0fc8

URL: https://github.com/llvm/llvm-project/commit/86d1ed9e480849ff57dfee23975165465ebe0fc8
DIFF: https://github.com/llvm/llvm-project/commit/86d1ed9e480849ff57dfee23975165465ebe0fc8.diff

LOG: [InlineCost] Avoid ConstantExpr::getSelect()

Instead use ConstantFoldSelectInstruction(), which will return
nullptr if it cannot be folded and a constant expression would
be produced instead.

In preparation for removing select constant expressions.

Added: 
    

Modified: 
    llvm/lib/Analysis/InlineCost.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp
index 5bcc8a2f384ad..f303670c72868 100644
--- a/llvm/lib/Analysis/InlineCost.cpp
+++ b/llvm/lib/Analysis/InlineCost.cpp
@@ -2314,10 +2314,10 @@ bool CallAnalyzer::visitSelectInst(SelectInst &SI) {
                                               : nullptr;
   if (!SelectedV) {
     // Condition is a vector constant that is not all 1s or all 0s.  If all
-    // operands are constants, ConstantExpr::getSelect() can handle the cases
-    // such as select vectors.
+    // operands are constants, ConstantFoldSelectInstruction() can handle the
+    // cases such as select vectors.
     if (TrueC && FalseC) {
-      if (auto *C = ConstantExpr::getSelect(CondC, TrueC, FalseC)) {
+      if (auto *C = ConstantFoldSelectInstruction(CondC, TrueC, FalseC)) {
         SimplifiedValues[&SI] = C;
         return true;
       }


        


More information about the llvm-commits mailing list