[llvm-bugs] [Bug 28964] New: [SimplifyCFG] failure to sink common function call below if/else
via llvm-bugs
llvm-bugs at lists.llvm.org
Sat Aug 13 06:23:11 PDT 2016
https://llvm.org/bugs/show_bug.cgi?id=28964
Bug ID: 28964
Summary: [SimplifyCFG] failure to sink common function call
below if/else
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: Transformation Utilities
Assignee: unassignedbugs at nondot.org
Reporter: spatel+llvm at rotateright.com
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
Forking this off from bug 28957:
extern int bar(int);
int foo(int x) {
if (x == 1)
return bar(1);
else
return bar(-1);
}
Or as optimized IR:
define i32 @foo(i32 %x) {
entry:
%cmp = icmp eq i32 %x, 1
br i1 %cmp, label %if.then, label %if.else
if.then:
%call = tail call i32 @bar(i32 1) #2
br label %return
if.else:
%call1 = tail call i32 @bar(i32 -1) #2
br label %return
return:
%retval.0 = phi i32 [ %call, %if.then ], [ %call1, %if.else ]
ret i32 %retval.0
}
declare i32 @bar(i32)
--------------------------------------------------------------------------
I think SimplifyCFG should transform this to the equivalent of:
int goo(int x) {
if (x == 1)
x = 1;
else
x = -1;
return bar(x);
}
which is this in IR:
define i32 @goo(i32 %x) local_unnamed_addr #0 {
%cmp = icmp eq i32 %x, 1
%sel = select i1 %cmp, i32 1, i32 -1
%call = tail call i32 @bar(i32 %sel)
ret i32 %call
}
--
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/20160813/30391335/attachment.html>
More information about the llvm-bugs
mailing list