[llvm] r272196 - [InstCombine] fix outdated comment, simplify logic; NFCI

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 8 13:31:52 PDT 2016


Author: spatel
Date: Wed Jun  8 15:31:52 2016
New Revision: 272196

URL: http://llvm.org/viewvc/llvm-project?rev=272196&view=rev
Log:
[InstCombine] fix outdated comment, simplify logic; NFCI

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

Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp?rev=272196&r1=272195&r2=272196&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp Wed Jun  8 15:31:52 2016
@@ -120,22 +120,19 @@ static Constant *GetSelectFoldableConsta
 /// have the same opcode and only one use each.  Try to simplify this.
 Instruction *InstCombiner::FoldSelectOpOp(SelectInst &SI, Instruction *TI,
                                           Instruction *FI) {
-  if (TI->getNumOperands() == 1) {
-    // If this is a non-volatile load or a cast from the same type,
-    // merge.
-    if (TI->isCast()) {
-      Type *FIOpndTy = FI->getOperand(0)->getType();
-      if (TI->getOperand(0)->getType() != FIOpndTy)
-        return nullptr;
-      // The select condition may be a vector. We may only change the operand
-      // type if the vector width remains the same (and matches the condition).
-      Type *CondTy = SI.getCondition()->getType();
-      if (CondTy->isVectorTy() && (!FIOpndTy->isVectorTy() ||
-          CondTy->getVectorNumElements() != FIOpndTy->getVectorNumElements()))
-        return nullptr;
-    } else {
-      return nullptr;  // unknown unary op.
-    }
+  // If this is a cast from the same type, merge.
+  if (TI->getNumOperands() == 1 && TI->isCast()) {
+    Type *FIOpndTy = FI->getOperand(0)->getType();
+    if (TI->getOperand(0)->getType() != FIOpndTy)
+      return nullptr;
+
+    // The select condition may be a vector. We may only change the operand
+    // type if the vector width remains the same (and matches the condition).
+    Type *CondTy = SI.getCondition()->getType();
+    if (CondTy->isVectorTy() &&
+        (!FIOpndTy->isVectorTy() ||
+         CondTy->getVectorNumElements() != FIOpndTy->getVectorNumElements()))
+      return nullptr;
 
     // Fold this by inserting a select from the input values.
     Value *NewSI = Builder->CreateSelect(SI.getCondition(), TI->getOperand(0),




More information about the llvm-commits mailing list