[llvm] e95fc20 - [X86] getFMA3OpcodeToCommuteOperands - use unreachable to detect fma3 format mismatch
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 10 09:14:49 PST 2022
Author: Simon Pilgrim
Date: 2022-02-10T17:14:39Z
New Revision: e95fc20f0463a27288407a4b67a7d71084666134
URL: https://github.com/llvm/llvm-project/commit/e95fc20f0463a27288407a4b67a7d71084666134
DIFF: https://github.com/llvm/llvm-project/commit/e95fc20f0463a27288407a4b67a7d71084666134.diff
LOG: [X86] getFMA3OpcodeToCommuteOperands - use unreachable to detect fma3 format mismatch
Matches what we do in getThreeSrcCommuteCase.
Fixes static analyzer out of bounds array access warning.
Added:
Modified:
llvm/lib/Target/X86/X86InstrInfo.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/X86/X86InstrInfo.cpp b/llvm/lib/Target/X86/X86InstrInfo.cpp
index 4dcd886fa3b2..d2b422172511 100644
--- a/llvm/lib/Target/X86/X86InstrInfo.cpp
+++ b/llvm/lib/Target/X86/X86InstrInfo.cpp
@@ -1957,14 +1957,13 @@ unsigned X86InstrInfo::getFMA3OpcodeToCommuteOperands(
FMAForms[0] = FMA3Group.get132Opcode();
FMAForms[1] = FMA3Group.get213Opcode();
FMAForms[2] = FMA3Group.get231Opcode();
- unsigned FormIndex;
- for (FormIndex = 0; FormIndex < 3; FormIndex++)
- if (Opc == FMAForms[FormIndex])
- break;
// Everything is ready, just adjust the FMA opcode and return it.
- FormIndex = FormMapping[Case][FormIndex];
- return FMAForms[FormIndex];
+ for (unsigned FormIndex = 0; FormIndex < 3; FormIndex++)
+ if (Opc == FMAForms[FormIndex])
+ return FMAForms[FormMapping[Case][FormIndex]];
+
+ llvm_unreachable("Illegal FMA3 format");
}
static void commuteVPTERNLOG(MachineInstr &MI, unsigned SrcOpIdx1,
More information about the llvm-commits
mailing list