[PATCH] D104037: [X86] Check immediate before get it.
LuoYuanke via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 10 07:58:40 PDT 2021
LuoYuanke created this revision.
Herald added subscribers: pengfei, hiraditya.
LuoYuanke requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
For CMP imm instruction, when the operand 1 is symbol address we should
check if it is immediate first. Here is the example code.
CMP64mi32 $noreg, 8, killed renamable $rcx, @d, $noreg, @a, implicit-def
$eflags
However I am not able to create a small test case to expose this issue.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D104037
Files:
llvm/lib/Target/X86/X86InstrInfo.cpp
Index: llvm/lib/Target/X86/X86InstrInfo.cpp
===================================================================
--- llvm/lib/Target/X86/X86InstrInfo.cpp
+++ llvm/lib/Target/X86/X86InstrInfo.cpp
@@ -6409,7 +6409,7 @@
case X86::CMP8ri: {
MachineOperand &MO0 = DataMI->getOperand(0);
MachineOperand &MO1 = DataMI->getOperand(1);
- if (MO1.getImm() == 0) {
+ if (MO1.isImm() && MO1.getImm() == 0) {
unsigned NewOpc;
switch (DataMI->getOpcode()) {
default: llvm_unreachable("Unreachable!");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104037.351176.patch
Type: text/x-patch
Size: 526 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210610/48b09b03/attachment.bin>
More information about the llvm-commits
mailing list