[llvm-bugs] [Bug 45073] New: false positive: MD_misexpect is not updated after the branch condition is flipped
via llvm-bugs
llvm-bugs at lists.llvm.org
Sun Mar 1 21:51:47 PST 2020
https://bugs.llvm.org/show_bug.cgi?id=45073
Bug ID: 45073
Summary: false positive: MD_misexpect is not updated after the
branch condition is flipped
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Transformation Utilities
Assignee: unassignedbugs at nondot.org
Reporter: wmi at google.com
CC: llvm-bugs at lists.llvm.org
We turned on -Wmisexpect and found some false positive warning. Here is a
testcase to show the problem. The cause is that MD_misexpect is not updated
after the branch condition is flipped. This looks like a general issue of
MD_misexpect.
---------------- 1.ll --------------------
declare void @goo()
declare i64 @llvm.expect.i64(i64, i64)
define void @foo(i1 %t0) {
%t1 = xor i1 %t0, true
%t2 = zext i1 %t1 to i64
%t4 = call i64 @llvm.expect.i64(i64 %t2, i64 0)
%t3 = icmp ne i64 %t2, 0
br i1 %t3, label %true, label %false, !prof !0, !misexpect !1
true:
call void @goo()
br label %false
false:
ret void
}
!0 = !{!"branch_weights", i32 1, i32 2000}
!1 = !{!"misexpect", i64 1, i64 2000, i64 1} ====> misexpect predicts else
branch is hot, which matches with !prof !0.
------------------------------------------
~/workarea/llvm/build/d20200121/bin/opt -instcombine -S 1.ll
Note that the branch condition is flipped after instcombine.
; ModuleID = '1.ll'
source_filename = "1.ll"
declare void @goo()
; Function Attrs: nounwind readnone willreturn
declare i64 @llvm.expect.i64(i64, i64) #0
define void @foo(i1 %t0) {
br i1 %t0, label %false, label %true, !prof !0, !misexpect !1
true: ; preds = %0
call void @goo()
br label %false
false: ; preds = %0, %true
ret void
}
attributes #0 = { nounwind readnone willreturn }
!0 = !{!"branch_weights", i32 2000, i32 1}
!1 = !{!"misexpect", i64 1, i64 2000, i64 1} ====> misexpect still predicts
else branch is hot, which contradicts with !prof !0.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200302/9778086a/attachment-0001.html>
More information about the llvm-bugs
mailing list