This implements a data flow reduction detection on basic block level. We propagate the used loads and the number of uses, as well as the kind of binary operation performed until we reach a store. Using this we lift the "one binary operator" restriction, thus we can detect the following reductions withouth normalizing the source code: sum += A[i]; // Worked already before sum = sum + A[i]; // Worked already before sum = A[i] + sum; // Worked already before sum += A[i] + B[i]; // Works now sum = A[i] + sum + B[i]; // Works now sum = (A[i] + (sum + B[i])); // Works now The analysis information is also interesting to recognize additional idioms later. + 7 Test cases to show the potential and limits of this detection.
Details
Diff Detail
Event Timeline
Without reviewing this code already in detail, I think this is very valuable. Specifically, it might allow us to (better) optimize the himeono benchmark (http://accc.riken.jp/2444.htm), which is also available in our test suite: ./SingleSource/Benchmarks/Misc/himenobmtxpa.c
I looked into the source but I cannot find a "complex reduction like access". Which line/variable did you have in mind?
Hi Johannes,
I am sorry I never got along to properly review this patch. I still think it is very much needed and useful so - depending of priorities - I will put this on my review agenda again.
Unfortunately, at the moment this is blocked by: http://llvm.org/PR26320
Set this official to "Request Changes" to clarify that we are blocked here by moving to the reductions to the schedule-tree based data-dependence analysis.