From: Craig Topper Date: Sat, 13 Aug 2016 06:48:44 +0000 (+0000) Subject: [X86] Add a check of isCommutable at the top of X86InstrInfo::findCommutedOpIndices... X-Git-Tag: llvmorg-4.0.0-rc1~12511 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8c372a31b7b91adad5566e6ae1436a65879d6025;p=platform%2Fupstream%2Fllvm.git [X86] Add a check of isCommutable at the top of X86InstrInfo::findCommutedOpIndices. Most callers don't check if the instruction is commutable before calling. This saves us the trouble of ending up in the default of the switch and having to determine if this is an FMA or not. llvm-svn: 278597 --- diff --git a/llvm/lib/Target/X86/X86InstrInfo.cpp b/llvm/lib/Target/X86/X86InstrInfo.cpp index 9df179d..caa9b85 100644 --- a/llvm/lib/Target/X86/X86InstrInfo.cpp +++ b/llvm/lib/Target/X86/X86InstrInfo.cpp @@ -3503,6 +3503,9 @@ bool X86InstrInfo::findFMA3CommutedOpIndices( bool X86InstrInfo::findCommutedOpIndices(MachineInstr &MI, unsigned &SrcOpIdx1, unsigned &SrcOpIdx2) const { + if (!MI.isCommutable()) + return false; + switch (MI.getOpcode()) { case X86::CMPPDrri: case X86::CMPPSrri: