[llvm-bugs] [Bug 34603] New: failed to hoist load through select-of-pointers?
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Sep 14 09:48:19 PDT 2017
https://bugs.llvm.org/show_bug.cgi?id=34603
Bug ID: 34603
Summary: failed to hoist load through select-of-pointers?
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
Forking this off from bug 28343:
double max_of_loads(double *x, double *y, int i) {
return x[i] > y[i] ? x[i] : y[i];
}
$ ./clang maxload.c -S -O2 -o - -emit-llvm
define double @max_of_loads(double* nocapture readonly %x, double* nocapture
readonly %y, i32 %i) {
entry:
%idxprom = sext i32 %i to i64
%arrayidx1 = getelementptr inbounds double, double* %x, i64 %idxprom
%0 = load double, double* %arrayidx1, align 8, !tbaa !3
%arrayidx2 = getelementptr inbounds double, double* %y, i64 %idxprom
%1 = load double, double* %arrayidx2, align 8, !tbaa !3
%cmp = fcmp ogt double %0, %1
%.sink = select i1 %cmp, double* %x, double* %y
%arrayidx6 = getelementptr inbounds double, double* %.sink, i64 %idxprom
%2 = load double, double* %arrayidx6, align 8, !tbaa !3
ret double %2
}
------------------------------------------------------------------------
I don't think there's any alias-based restrictions impeding this transform?
define double @max_of_loads(double* nocapture readonly %x, double* nocapture
readonly %y, i32 %i) {
entry:
%idxprom = sext i32 %i to i64
%arrayidx = getelementptr inbounds double, double* %x, i64 %idxprom
%arrayidx2 = getelementptr inbounds double, double* %y, i64 %idxprom
%0 = load double, double* %arrayidx, align 8, !tbaa !3
%1 = load double, double* %arrayidx2, align 8, !tbaa !3
%cmp = fcmp ogt double %0, %1
%sel = select i1 %cmp, double %0, double %1
ret double %sel
}
--
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/20170914/fd9cd6fb/attachment.html>
More information about the llvm-bugs
mailing list