[llvm-commits] [llvm] r57551 - /llvm/trunk/lib/Target/X86/X86FastISel.cpp
Chris Lattner
sabre at nondot.org
Tue Oct 14 21:32:45 PDT 2008
Author: lattner
Date: Tue Oct 14 23:32:45 2008
New Revision: 57551
URL: http://llvm.org/viewvc/llvm-project?rev=57551&view=rev
Log:
Use switch on VT instead of Type* comparisons.
Modified:
llvm/trunk/lib/Target/X86/X86FastISel.cpp
Modified: llvm/trunk/lib/Target/X86/X86FastISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FastISel.cpp?rev=57551&r1=57550&r2=57551&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86FastISel.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86FastISel.cpp Tue Oct 14 23:32:45 2008
@@ -519,36 +519,35 @@
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 @@
// 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;
More information about the llvm-commits
mailing list