From 7b66e041821309306beccda0fe58ffa096ee1f4a Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Tue, 21 Oct 2008 18:24:51 +0000 Subject: [PATCH] Implement the optimized FCMP_OEQ/FCMP_UNE code for x86 fast-isel. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57915 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/X86FastISel.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/Target/X86/X86FastISel.cpp b/lib/Target/X86/X86FastISel.cpp index 6284bba0927..b280d652901 100644 --- a/lib/Target/X86/X86FastISel.cpp +++ b/lib/Target/X86/X86FastISel.cpp @@ -692,6 +692,11 @@ bool X86FastISel::X86SelectBranch(Instruction *I) { unsigned BranchOpc; // Opcode to jump on, e.g. "X86::JA" switch (Predicate) { + case CmpInst::FCMP_OEQ: + std::swap(TrueMBB, FalseMBB); + Predicate = CmpInst::FCMP_UNE; + // FALL THROUGH + case CmpInst::FCMP_UNE: SwapArgs = false; BranchOpc = X86::JNE; break; case CmpInst::FCMP_OGT: SwapArgs = false; BranchOpc = X86::JA; break; case CmpInst::FCMP_OGE: SwapArgs = false; BranchOpc = X86::JAE; break; case CmpInst::FCMP_OLT: SwapArgs = true; BranchOpc = X86::JA; break; @@ -728,6 +733,13 @@ bool X86FastISel::X86SelectBranch(Instruction *I) { return false; BuildMI(MBB, TII.get(BranchOpc)).addMBB(TrueMBB); + + if (Predicate == CmpInst::FCMP_UNE) { + // X86 requires a second branch to handle UNE (and OEQ, + // which is mapped to UNE above). + BuildMI(MBB, TII.get(X86::JP)).addMBB(TrueMBB); + } + FastEmitBranch(FalseMBB); MBB->addSuccessor(TrueMBB); return true;