[llvm] d034c18 - [LLParser] Remove unnecessary switch from the handling of the remaini… (#67362)

via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 25 13:40:04 PDT 2023


Author: Craig Topper
Date: 2023-09-25T13:40:00-07:00
New Revision: d034c18e7c7d24b4b32817b9051f41d5cd92d7ec

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

LOG: [LLParser] Remove unnecessary switch from the handling of the remaini… (#67362)

…ng binary constantexprs.

FP binary operators aren't supported anymore, so we don't need a switch
to pick whether we expect an integer or FP type.

Added: 
    

Modified: 
    llvm/lib/AsmParser/LLParser.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index f1f0cdf746ee12a..a451aa508a55577 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -3933,30 +3933,8 @@ bool LLParser::parseValID(ValID &ID, PerFunctionState *PFS, Type *ExpectedTy) {
     if (Val0->getType() != Val1->getType())
       return error(ID.Loc, "operands of constexpr must have same type");
     // Check that the type is valid for the operator.
-    switch (Opc) {
-    case Instruction::Add:
-    case Instruction::Sub:
-    case Instruction::Mul:
-    case Instruction::UDiv:
-    case Instruction::SDiv:
-    case Instruction::URem:
-    case Instruction::SRem:
-    case Instruction::Shl:
-    case Instruction::AShr:
-    case Instruction::LShr:
-      if (!Val0->getType()->isIntOrIntVectorTy())
-        return error(ID.Loc, "constexpr requires integer operands");
-      break;
-    case Instruction::FAdd:
-    case Instruction::FSub:
-    case Instruction::FMul:
-    case Instruction::FDiv:
-    case Instruction::FRem:
-      if (!Val0->getType()->isFPOrFPVectorTy())
-        return error(ID.Loc, "constexpr requires fp operands");
-      break;
-    default: llvm_unreachable("Unknown binary operator!");
-    }
+    if (!Val0->getType()->isIntOrIntVectorTy())
+      return error(ID.Loc, "constexpr requires integer operands");
     unsigned Flags = 0;
     if (NUW)   Flags |= OverflowingBinaryOperator::NoUnsignedWrap;
     if (NSW)   Flags |= OverflowingBinaryOperator::NoSignedWrap;


        


More information about the llvm-commits mailing list