aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-10-15 04:29:23 +0000
committerChris Lattner <sabre@nondot.org>2008-10-15 04:29:23 +0000
commit51ccb3deba7ccf2a3f154a9c4e4182146eccc846 (patch)
treeaaa89f204fb4f48deb2b3bb6dab49a3fafffb897
parent9a08a61d7908004b061d560b11917e5c1c7ecc02 (diff)
Use X86FastEmitCompare for FCMP_OEQ and FCMP_UNE: it doesn't
change the generated code, but makes the code simpler. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57550 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Target/X86/X86FastISel.cpp25
1 files changed, 8 insertions, 17 deletions
diff --git a/lib/Target/X86/X86FastISel.cpp b/lib/Target/X86/X86FastISel.cpp
index 1765e9e1de..9197bab552 100644
--- a/lib/Target/X86/X86FastISel.cpp
+++ b/lib/Target/X86/X86FastISel.cpp
@@ -101,8 +101,6 @@ private:
bool X86SelectTrunc(Instruction *I);
- unsigned X86ChooseCmpOpcode(MVT VT);
-
bool X86SelectFPExt(Instruction *I);
bool X86SelectFPTrunc(Instruction *I);
@@ -519,7 +517,7 @@ bool X86FastISel::X86SelectLoad(Instruction *I) {
return false;
}
-unsigned X86FastISel::X86ChooseCmpOpcode(MVT VT) {
+static unsigned X86ChooseCmpOpcode(MVT VT) {
switch (VT.getSimpleVT()) {
case MVT::i8: return X86::CMP8rr;
case MVT::i16: return X86::CMP16rr;
@@ -590,15 +588,11 @@ bool X86FastISel::X86SelectCmp(Instruction *I) {
bool SwapArgs; // false -> compare Op0, Op1. true -> compare Op1, Op0.
switch (CI->getPredicate()) {
case CmpInst::FCMP_OEQ: {
- unsigned Op0Reg = getRegForValue(CI->getOperand(0));
- if (Op0Reg == 0) return false;
- unsigned Op1Reg = getRegForValue(CI->getOperand(1));
- if (Op1Reg == 0) return false;
- unsigned Opc = X86ChooseCmpOpcode(VT);
+ if (!X86FastEmitCompare(CI->getOperand(0), CI->getOperand(1), VT))
+ return false;
unsigned EReg = createResultReg(&X86::GR8RegClass);
unsigned NPReg = createResultReg(&X86::GR8RegClass);
- BuildMI(MBB, TII.get(Opc)).addReg(Op0Reg).addReg(Op1Reg);
BuildMI(MBB, TII.get(X86::SETEr), EReg);
BuildMI(MBB, TII.get(X86::SETNPr), NPReg);
BuildMI(MBB, TII.get(X86::AND8rr), ResultReg).addReg(NPReg).addReg(EReg);
@@ -606,15 +600,11 @@ bool X86FastISel::X86SelectCmp(Instruction *I) {
return true;
}
case CmpInst::FCMP_UNE: {
- unsigned Op0Reg = getRegForValue(CI->getOperand(0));
- if (Op0Reg == 0) return false;
- unsigned Op1Reg = getRegForValue(CI->getOperand(1));
- if (Op1Reg == 0) return false;
- unsigned Opc = X86ChooseCmpOpcode(VT);
-
+ if (!X86FastEmitCompare(CI->getOperand(0), CI->getOperand(1), VT))
+ return false;
+
unsigned NEReg = createResultReg(&X86::GR8RegClass);
unsigned PReg = createResultReg(&X86::GR8RegClass);
- BuildMI(MBB, TII.get(Opc)).addReg(Op0Reg).addReg(Op1Reg);
BuildMI(MBB, TII.get(X86::SETNEr), NEReg);
BuildMI(MBB, TII.get(X86::SETPr), PReg);
BuildMI(MBB, TII.get(X86::OR8rr), ResultReg).addReg(PReg).addReg(NEReg);
@@ -653,7 +643,8 @@ bool X86FastISel::X86SelectCmp(Instruction *I) {
std::swap(Op0, Op1);
// Emit a compare of Op0/Op1.
- X86FastEmitCompare(Op0, Op1, VT);
+ if (!X86FastEmitCompare(Op0, Op1, VT))
+ return false;
BuildMI(MBB, TII.get(SetCCOpc), ResultReg);
UpdateValueMap(I, ResultReg);