[llvm] r348853 - Fix not correct imm operand assertion for SUB32ri in X86CondBrFolding::analyzeCompare
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 11 07:32:14 PST 2018
Author: ctopper
Date: Tue Dec 11 07:32:14 2018
New Revision: 348853
URL: http://llvm.org/viewvc/llvm-project?rev=348853&view=rev
Log:
Fix not correct imm operand assertion for SUB32ri in X86CondBrFolding::analyzeCompare
Summary:
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
Patch by Jianping Chen
Reviewers: smaslov, LuoYuanke, liutianle, Jianping
Reviewed By: Jianping
Subscribers: lebedev.ri, llvm-commits
Differential Revision: https://reviews.llvm.org/D54250
Added:
llvm/trunk/test/CodeGen/X86/test_x86condbr_globaladdr.mir
Modified:
llvm/trunk/lib/Target/X86/X86CondBrFolding.cpp
Modified: llvm/trunk/lib/Target/X86/X86CondBrFolding.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86CondBrFolding.cpp?rev=348853&r1=348852&r2=348853&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86CondBrFolding.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86CondBrFolding.cpp Tue Dec 11 07:32:14 2018
@@ -468,7 +468,8 @@ bool X86CondBrFolding::analyzeCompare(co
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;
}
Added: llvm/trunk/test/CodeGen/X86/test_x86condbr_globaladdr.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/test_x86condbr_globaladdr.mir?rev=348853&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/test_x86condbr_globaladdr.mir (added)
+++ llvm/trunk/test/CodeGen/X86/test_x86condbr_globaladdr.mir Tue Dec 11 07:32:14 2018
@@ -0,0 +1,30 @@
+# RUN: llc -o - %s -mtriple=i686-- -mcpu=ivybridge --run-pass X86CondBrFolding | FileCheck %s
+
+# Test wrong assertion when meet SUB32ri with global address
+# in X86CondBrFoldingiPass
+--- |
+ @img2buf_normal = external global i32
+ define void @func() { ret void }
+...
+---
+# CHECK: bb.0:
+# CHECK: %2:gr32 = SUB32ri %1, @img2buf_normal, implicit-def $eflags
+
+name: func
+tracksRegLiveness: true
+body: |
+ bb.0:
+ liveins: $edx
+ %1:gr32 = COPY $edx
+ %2:gr32 = MOV32rm %1:gr32, 1, $noreg, 850256, $noreg
+ %3:gr32 = SUB32ri %2:gr32, @img2buf_normal, implicit-def $eflags
+ JE_1 %bb.2, implicit $eflags
+ JMP_1 %bb.3
+
+ bb.2:
+ RET 0, undef $eax
+
+ bb.3:
+ $eax = MOV32rr %3:gr32
+ RET 0, $eax
+...
More information about the llvm-commits
mailing list