diff options
author | Chris Lattner <sabre@nondot.org> | 2008-10-15 04:32:45 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-10-15 04:32:45 +0000 |
commit | 44384eb7c8d3186d5f2da01f4962c80590f5ff82 (patch) | |
tree | bd25706ada4ac6013de24055d7165d36a7e0fb65 | |
parent | ee82bd54015a326ad384d210ce96ebaf93370e87 (diff) | |
download | external_llvm-44384eb7c8d3186d5f2da01f4962c80590f5ff82.zip external_llvm-44384eb7c8d3186d5f2da01f4962c80590f5ff82.tar.gz external_llvm-44384eb7c8d3186d5f2da01f4962c80590f5ff82.tar.bz2 |
Use switch on VT instead of Type* comparisons.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57551 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Target/X86/X86FastISel.cpp | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/lib/Target/X86/X86FastISel.cpp b/lib/Target/X86/X86FastISel.cpp index 9197bab..8d85733 100644 --- a/lib/Target/X86/X86FastISel.cpp +++ b/lib/Target/X86/X86FastISel.cpp @@ -519,36 +519,35 @@ bool X86FastISel::X86SelectLoad(Instruction *I) { static unsigned X86ChooseCmpOpcode(MVT VT) { switch (VT.getSimpleVT()) { - case MVT::i8: return X86::CMP8rr; + default: return 0; + case MVT::i8: return X86::CMP8rr; case MVT::i16: return X86::CMP16rr; case MVT::i32: return X86::CMP32rr; case MVT::i64: return X86::CMP64rr; case MVT::f32: return X86::UCOMISSrr; case MVT::f64: return X86::UCOMISDrr; - default: break; } - return 0; + } /// X86ChooseCmpImmediateOpcode - If we have a comparison with RHS as the RHS /// of the comparison, return an opcode that works for the compare (e.g. /// CMP32ri) otherwise return 0. -static unsigned X86ChooseCmpImmediateOpcode(ConstantInt *RHSC) { - if (RHSC->getType() == Type::Int8Ty) - return X86::CMP8ri; - if (RHSC->getType() == Type::Int16Ty) - return X86::CMP16ri; - if (RHSC->getType() == Type::Int32Ty) - return X86::CMP32ri; - - // 64-bit comparisons are only valid if the immediate fits in a 32-bit sext - // field. - if (RHSC->getType() == Type::Int64Ty && - (int)RHSC->getSExtValue() == RHSC->getSExtValue()) - return X86::CMP64ri32; - +static unsigned X86ChooseCmpImmediateOpcode(MVT VT, ConstantInt *RHSC) { + switch (VT.getSimpleVT()) { // Otherwise, we can't fold the immediate into this comparison. - return 0; + default: return 0; + case MVT::i8: return X86::CMP8ri; + case MVT::i16: return X86::CMP16ri; + case MVT::i32: return X86::CMP32ri; + case MVT::i64: + // 64-bit comparisons are only valid if the immediate fits in a 32-bit sext + // field. + if (RHSC->getType() == Type::Int64Ty && + (int)RHSC->getSExtValue() == RHSC->getSExtValue()) + return X86::CMP64ri32; + return 0; + } } bool X86FastISel::X86FastEmitCompare(Value *Op0, Value *Op1, MVT VT) { @@ -559,7 +558,7 @@ bool X86FastISel::X86FastEmitCompare(Value *Op0, Value *Op1, MVT VT) { // the compare is an immediate that we can fold into this compare, use // CMPri, otherwise use CMPrr. if (ConstantInt *Op1C = dyn_cast<ConstantInt>(Op1)) { - if (unsigned CompareImmOpc = X86ChooseCmpImmediateOpcode(Op1C)) { + if (unsigned CompareImmOpc = X86ChooseCmpImmediateOpcode(VT, Op1C)) { BuildMI(MBB, TII.get(CompareImmOpc)).addReg(Op0Reg) .addImm(Op1C->getSExtValue()); return true; |