[llvm] 34c33bb - [InstCombine] Remove redundant fold in foldSelectExtConst() (NFCI)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 24 07:24:59 PDT 2023


Author: Nikita Popov
Date: 2023-10-24T16:24:27+02:00
New Revision: 34c33bbb8bfddf743fd9b077fd42f76bcce1e0f3

URL: https://github.com/llvm/llvm-project/commit/34c33bbb8bfddf743fd9b077fd42f76bcce1e0f3
DIFF: https://github.com/llvm/llvm-project/commit/34c33bbb8bfddf743fd9b077fd42f76bcce1e0f3.diff

LOG: [InstCombine] Remove redundant fold in foldSelectExtConst() (NFCI)

This has been subsumed by the more general simplifyWithOpReplaced()
fold.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
index cbc2f8355a6cc55..216949c7f91b91a 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -2100,24 +2100,6 @@ Instruction *InstCombinerImpl::foldSelectExtConst(SelectInst &Sel) {
     return CastInst::Create(Instruction::CastOps(ExtOpcode), NewSel, SelType);
   }
 
-  // If one arm of the select is the extend of the condition, replace that arm
-  // with the extension of the appropriate known bool value.
-  if (Cond == X) {
-    if (ExtInst == Sel.getTrueValue()) {
-      // select X, (sext X), C --> select X, -1, C
-      // select X, (zext X), C --> select X,  1, C
-      Constant *One = ConstantInt::getTrue(SmallType);
-      Value *AllOnesOrOne =
-          Builder.CreateCast((Instruction::CastOps)ExtOpcode, One, SelType);
-      return SelectInst::Create(Cond, AllOnesOrOne, C, "", nullptr, &Sel);
-    } else {
-      // select X, C, (sext X) --> select X, C, 0
-      // select X, C, (zext X) --> select X, C, 0
-      Constant *Zero = ConstantInt::getNullValue(SelType);
-      return SelectInst::Create(Cond, C, Zero, "", nullptr, &Sel);
-    }
-  }
-
   return nullptr;
 }
 


        


More information about the llvm-commits mailing list