diff options
author | Craig Topper <craig.topper@intel.com> | 2019-05-05 17:19:16 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@intel.com> | 2019-05-05 17:19:16 +0000 |
commit | 41c999bcf5e7654f3b7098907377a786c301b606 (patch) | |
tree | 69acca35adcf9a6ece69b490a8c77bc5bbae23b0 /llvm/lib/IR/Constants.cpp | |
parent | 4c3fbbf635920206eff5fe0c4aa2eea96a0a52f9 (diff) | |
download | llvm-41c999bcf5e7654f3b7098907377a786c301b606.zip llvm-41c999bcf5e7654f3b7098907377a786c301b606.tar.gz llvm-41c999bcf5e7654f3b7098907377a786c301b606.tar.bz2 |
[Constants] Simplify type checking switch in ConstantExpr::get.
Summary:
Remove duplicate checks that both operands have the same type. This is checked
before the switch.
Use 'integer' or 'floating-point' instead of 'arithmetic' type. I think this
might be a leftover to the days when floating point and integer operations
shared the same opcodes.
Reviewers: spatel, RKSimon, dblaikie
Reviewed By: RKSimon
Subscribers: hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D61558
llvm-svn: 359985
Diffstat (limited to 'llvm/lib/IR/Constants.cpp')
-rw-r--r-- | llvm/lib/IR/Constants.cpp | 32 |
1 files changed, 6 insertions, 26 deletions
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp index 5545eb4..ff551da 100644 --- a/llvm/lib/IR/Constants.cpp +++ b/llvm/lib/IR/Constants.cpp @@ -1856,51 +1856,31 @@ Constant *ConstantExpr::get(unsigned Opcode, Constant *C1, Constant *C2, case Instruction::Add: case Instruction::Sub: case Instruction::Mul: - assert(C1->getType() == C2->getType() && "Op types should be identical!"); + case Instruction::UDiv: + case Instruction::SDiv: + case Instruction::URem: + case Instruction::SRem: assert(C1->getType()->isIntOrIntVectorTy() && "Tried to create an integer operation on a non-integer type!"); break; case Instruction::FAdd: case Instruction::FSub: case Instruction::FMul: - assert(C1->getType() == C2->getType() && "Op types should be identical!"); - assert(C1->getType()->isFPOrFPVectorTy() && - "Tried to create a floating-point operation on a " - "non-floating-point type!"); - break; - case Instruction::UDiv: - case Instruction::SDiv: - assert(C1->getType() == C2->getType() && "Op types should be identical!"); - assert(C1->getType()->isIntOrIntVectorTy() && - "Tried to create an arithmetic operation on a non-arithmetic type!"); - break; case Instruction::FDiv: - assert(C1->getType() == C2->getType() && "Op types should be identical!"); - assert(C1->getType()->isFPOrFPVectorTy() && - "Tried to create an arithmetic operation on a non-arithmetic type!"); - break; - case Instruction::URem: - case Instruction::SRem: - assert(C1->getType() == C2->getType() && "Op types should be identical!"); - assert(C1->getType()->isIntOrIntVectorTy() && - "Tried to create an arithmetic operation on a non-arithmetic type!"); - break; case Instruction::FRem: - assert(C1->getType() == C2->getType() && "Op types should be identical!"); assert(C1->getType()->isFPOrFPVectorTy() && - "Tried to create an arithmetic operation on a non-arithmetic type!"); + "Tried to create a floating-point operation on a " + "non-floating-point type!"); break; case Instruction::And: case Instruction::Or: case Instruction::Xor: - assert(C1->getType() == C2->getType() && "Op types should be identical!"); assert(C1->getType()->isIntOrIntVectorTy() && "Tried to create a logical operation on a non-integral type!"); break; case Instruction::Shl: case Instruction::LShr: case Instruction::AShr: - assert(C1->getType() == C2->getType() && "Op types should be identical!"); assert(C1->getType()->isIntOrIntVectorTy() && "Tried to create a shift operation on a non-integer type!"); break; |