[llvm-bugs] [Bug 33084] New: SimplifyCFG sinks instructions too aggressively
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed May 17 19:26:22 PDT 2017
https://bugs.llvm.org/show_bug.cgi?id=33084
Bug ID: 33084
Summary: SimplifyCFG sinks instructions too aggressively
Product: libraries
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: Transformation Utilities
Assignee: unassignedbugs at nondot.org
Reporter: efriedma at codeaurora.org
CC: james.molloy at arm.com, llvm-bugs at lists.llvm.org
Testcase:
int f(int a, int b, int g(void)) {
int c;
if (g) {
g(); c = (a + 31) & -32;
} else {
c = (b + 62) & -64;
}
return c;
}
Pass this to clang -O2, and you get IR something like this:
define i32 @f(i32 %a, i32 %b, i32 ()* %g) local_unnamed_addr #0 {
entry:
%tobool = icmp eq i32 ()* %g, null
br i1 %tobool, label %if.else, label %if.then
if.then: ; preds = %entry
%call = tail call i32 %g() #1
%add = add nsw i32 %a, 31
br label %if.end
if.else: ; preds = %entry
%add1 = add nsw i32 %b, 62
br label %if.end
if.end: ; preds = %if.else, %if.then
%.sink = phi i32 [ -64, %if.else ], [ -32, %if.then ]
%add1.sink = phi i32 [ %add1, %if.else ], [ %add, %if.then ]
%and2 = and i32 %add1.sink, %.sink
ret i32 %and2
}
Sinking the "and" here might not make sense: we're generating two phi nodes to
remove one "and" instruction.
We started sinking the "and" in r280351.
I'm planning to continue looking into this, but suggestions welcome.
--
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/20170518/7f6bb2d1/attachment.html>
More information about the llvm-bugs
mailing list