[PATCH] D54250: Fix not correct imm operand assertion for SUB32ri in X86CondBrFolding::analyzeCompare

Chen Jianping via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 7 23:55:32 PST 2018


Jianping created this revision.
Jianping added reviewers: craig.topper, smaslov, LuoYuanke, liutianle.
Herald added a subscriber: llvm-commits.

When doing X86CondBrFolding::analyzeCompare, it will meet the SUB32ri instruction as below to use the global address for its operand,

  %733:gr32 = SUB32ri %62:gr32(tied-def 0), @img2buf_normal, implicit-def $eflags
  JNE_1 %bb.41, implicit $eflags

so the assertion "assert(MI.getOperand(ValueIndex).isImm() && "Expecting Imm operand")" is not correct and change the assert to if make X86CondBrFolding::analyzeCompare return false as not finding the compare for this


Repository:
  rL LLVM

https://reviews.llvm.org/D54250

Files:
  lib/Target/X86/X86CondBrFolding.cpp


Index: lib/Target/X86/X86CondBrFolding.cpp
===================================================================
--- lib/Target/X86/X86CondBrFolding.cpp
+++ lib/Target/X86/X86CondBrFolding.cpp
@@ -466,7 +466,8 @@
     break;
   }
   SrcReg = MI.getOperand(SrcRegIndex).getReg();
-  assert(MI.getOperand(ValueIndex).isImm() && "Expecting Imm operand");
+  if (!MI.getOperand(ValueIndex).isImm())
+    return false;
   CmpValue = MI.getOperand(ValueIndex).getImm();
   return true;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54250.173122.patch
Type: text/x-patch
Size: 481 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181108/4280288d/attachment.bin>


More information about the llvm-commits mailing list