From 8c372a31b7b91adad5566e6ae1436a65879d6025 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Sat, 13 Aug 2016 06:48:44 +0000 Subject: [PATCH] [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 --- llvm/lib/Target/X86/X86InstrInfo.cpp | 3 +++ 1 file changed, 3 insertions(+) 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: -- 2.7.4