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: unassignedb...@nondot.org
Reporter: spatel+l...@rotateright.com
CC: llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs