[PATCH] D61555: Remove BinaryOpsEnd case from ConstantFoldBinaryInstruction(...)

Cameron McInally via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat May 4 17:03:53 PDT 2019


cameron.mcinally created this revision.
cameron.mcinally added reviewers: spatel, arsenm.
Herald added subscribers: llvm-commits, hiraditya, wdng.
Herald added a project: LLVM.

@spatel noticed this in another proposed patch. The `isBinaryOp` assert at the beginning of `ConstantFoldBinaryInstruction(...)` ensures that a `BinaryOpsEnd` will never reach this switch.

I've confirmed that all current BinaryOp Instructions are covered in this switch, so it should be safe to change this case to the default case.


Repository:
  rL LLVM

https://reviews.llvm.org/D61555

Files:
  llvm/lib/IR/ConstantFold.cpp


Index: llvm/lib/IR/ConstantFold.cpp
===================================================================
--- llvm/lib/IR/ConstantFold.cpp
+++ llvm/lib/IR/ConstantFold.cpp
@@ -972,6 +972,8 @@
                         (isa<UndefValue>(C1) || isa<UndefValue>(C2));
   if (HasScalarUndef) {
     switch (static_cast<Instruction::BinaryOps>(Opcode)) {
+    default:
+      llvm_unreachable("Invalid BinaryOp");
     case Instruction::Xor:
       if (isa<UndefValue>(C1) && isa<UndefValue>(C2))
         // Handle undef ^ undef -> 0 special case. This is a common
@@ -1067,8 +1069,6 @@
       // NaN because we can choose the undef operand as NaN, and any FP opcode
       // with a NaN operand will propagate NaN.
       return ConstantFP::getNaN(C1->getType());
-    case Instruction::BinaryOpsEnd:
-      llvm_unreachable("Invalid BinaryOp");
     }
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61555.198150.patch
Type: text/x-patch
Size: 853 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190505/5bd2296c/attachment.bin>


More information about the llvm-commits mailing list