[llvm-bugs] [Bug 39603] New: failed to eliminate conditional memops
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Nov 9 08:39:20 PST 2018
https://bugs.llvm.org/show_bug.cgi?id=39603
Bug ID: 39603
Summary: failed to eliminate conditional memops
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: spatel+llvm at rotateright.com
CC: llvm-bugs at lists.llvm.org
This probably doesn't do anything for bug 39597, but we're missing some
fundamental transforms before we get to anything more complicated:
void always_store(int* x, int exchangeVal) {
*x = (*x != exchangeVal) ? exchangeVal : *x;
}
void never_store(int* x, int exchangeVal) {
*x = (*x == exchangeVal) ? exchangeVal : *x;
}
void conditional_always_store(int* x, int exchangeVal) {
if (*x != exchangeVal)
*x = exchangeVal;
}
void conditional_never_store(int* x, int exchangeVal) {
if (*x == exchangeVal)
*x = exchangeVal;
}
https://godbolt.org/z/En099n
As optimized IR:
define void @always_store(i32* nocapture %x, i32 %exchangeVal) {
store i32 %exchangeVal, i32* %x, align 4
ret void
}
define void @never_store(i32* nocapture %x, i32 %exchangeVal) {
ret void
}
define void @conditional_always_store(i32* nocapture %x, i32 %exchangeVal) {
entry:
%0 = load i32, i32* %x, align 4
%cmp = icmp eq i32 %0, %exchangeVal
br i1 %cmp, label %if.end, label %if.then
if.then:
store i32 %exchangeVal, i32* %x, align 4
br label %if.end
if.end:
ret void
}
define void @conditional_never_store(i32* nocapture %x, i32 %exchangeVal) {
entry:
%0 = load i32, i32* %x, align 4
%cmp = icmp eq i32 %0, %exchangeVal
br i1 %cmp, label %if.then, label %if.end
if.then:
store i32 %exchangeVal, i32* %x, align 4
br label %if.end
if.end:
ret void
}
--
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/20181109/94b401b9/attachment.html>
More information about the llvm-bugs
mailing list