https://llvm.org/bugs/show_bug.cgi?id=26636
Bug ID: 26636 Summary: [SimplifyCFG] branch weights are not preserved when forming select Product: libraries Version: trunk Hardware: PC OS: All Status: NEW Severity: normal Priority: P Component: Transformation Utilities Assignee: unassignedb...@nondot.org Reporter: spatel+l...@rotateright.com CC: llvm-bugs@lists.llvm.org Classification: Unclassified The conditional branch has profile weight metadata: target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-apple-macosx10.11.0" define i32 @foo(i32 %x) #0 { entry: %cmp = icmp sgt i32 %x, 4 br i1 %cmp, label %if.then, label %if.end, !prof !0 if.then: %add = add nsw i32 %x, 7 br label %return if.end: %mul = mul nsw i32 %x, 17 br label %return return: %retval.0 = phi i32 [ %add, %if.then ], [ %mul, %if.end ] ret i32 %retval.0 } !0 = !{!"branch_weights", i32 676, i32 207} ------------------------------------------------------------------------------- But after -simplifycfg, the metadata is gone: $ ./opt -simplifycfg selbrweight.ll -S ; ModuleID = 'selbrweight.ll' target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-apple-macosx10.11.0" define i32 @foo(i32 %x) { entry: %cmp = icmp sgt i32 %x, 4 %add = add nsw i32 %x, 7 %mul = mul nsw i32 %x, 17 %retval.0 = select i1 %cmp, i32 %add, i32 %mul ret i32 %retval.0 } ------------------------------------------------------------------------------- I don't know if weight metadata can currently be applied to selects, but the select instruction should propagate the weight info that was on the branch. This was noted by Benjamin Kramer in: http://reviews.llvm.org/D16836 -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs