Open Quuxplusone opened 5 years ago
Bugzilla Link | PR40066 |
Status | NEW |
Importance | P enhancement |
Reported by | Moritz Kreutzer (moritz.kreutzer@siemens.com) |
Reported on | 2018-12-18 02:14:18 -0800 |
Last modified on | 2018-12-20 04:38:59 -0800 |
Version | trunk |
Hardware | PC Linux |
CC | hfinkel@anl.gov, hideki.saito@intel.com, llvm-bugs@lists.llvm.org |
Fixed by commit(s) | |
Attachments | |
Blocks | |
Blocked by | |
See also |
I investigated a bit further regarding the vectorization of
dst[i] = std::min(dst[i], dst[i]/src[i])
Remember that std::min() is implemented along the lines of:
double const & std::min(double const & a, double const & b)
{
if (a<b) return a;
return b;
}
The debug output indicates that the access analysis fails for a bitcast:
LAA: Can't find bounds for ptr: %2 = bitcast double* %a.b.i to i64*, !dbg !23
Where %a.b.i seems to hold the result of the call to std::min():
%div = fdiv double %0, %1
store double %div, double* %ref.tmp, align 8, !tbaa !2, !llvm.access.group !6
%cmp.i = fcmp olt double %0, %div
%a.b.i = select i1 %cmp.i, double* %arrayidx, double* %ref.tmp
%2 = bitcast double* %a.b.i to i64*
The exact place of failure on LoopAccessAnalysis is in hasComputableBounds(),
where the dynamic_cast of the pointer to SCEVAddRecExpr fails and Assume ==
false:
const SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(PtrScev);
if (!AR && Assume) AR = PSE.getAsAddRec(Ptr);
if (!AR) return false;
While I can imagine that the present semantics (mixture of temporary values and
referencse) are not trivial for access analysis, I doubt that it's impossible
to safely vectorize this loop. As I said before, merely changing the return
type of std::min() to "double" enables vectorization for this loop, probably
because we are creating a copy at one point.
I'm not exactly sure what's happening here. I just wanted to share my thoughts
and hope that it helps or someone can point me in the right direction. I can
provide more information if required.
Moritz