[llvm] 9d03b7d - [InstCombine] Use swapValues(); NFC

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 8 07:58:07 PST 2020


Author: Nikita Popov
Date: 2020-02-08T16:57:28+01:00
New Revision: 9d03b7d0d00833d81f31ff740491af6211262209

URL: https://github.com/llvm/llvm-project/commit/9d03b7d0d00833d81f31ff740491af6211262209
DIFF: https://github.com/llvm/llvm-project/commit/9d03b7d0d00833d81f31ff740491af6211262209.diff

LOG: [InstCombine] Use swapValues(); NFC

Less code, and makes it more obvious that these operands do not
need to be added back to the worklist.

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 414c46427231..2c2188b91975 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -2401,8 +2401,7 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) {
     // Swap true/false values and condition.
     CmpInst *Cond = cast<CmpInst>(CondVal);
     Cond->setPredicate(CmpInst::getInversePredicate(Pred));
-    SI.setOperand(1, FalseVal);
-    SI.setOperand(2, TrueVal);
+    SI.swapValues();
     SI.swapProfMetadata();
     Worklist.push(Cond);
     return &SI;
@@ -2783,8 +2782,7 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) {
   Value *NotCond;
   if (match(CondVal, m_Not(m_Value(NotCond)))) {
     SI.setOperand(0, NotCond);
-    SI.setOperand(1, FalseVal);
-    SI.setOperand(2, TrueVal);
+    SI.swapValues();
     SI.swapProfMetadata();
     return &SI;
   }


        


More information about the llvm-commits mailing list