This patch provides a simplified version of the Any intrinsic as well as the All intrinsic
that can be used for inlining or simpiler use cases. These changes are targeting exchange2, and
provide a ~9% performance increase.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp | ||
---|---|---|
267 | As discussed in private confersation, I think we should refactor this to not duplicate quite so much code. Whether we do that the way I suggested, or some other way is less important. Writing this here just so others know what's going on... :) | |
473 | We could porbably have a genAnyOrAll that takes the genBodyOp and has all the common code. | |
807 | Soemthing like "getDimCount returns a rank of zero" is more accurate. The "is set to 0" implies that the compiler gives that value somewhere else. (This applies to other places with same comment) | |
flang/test/Transforms/simplifyintrinsics.fir | ||
1246 | Although it doesn't really matter that much, it helps a little bit if you name the functions differently, rather than having several tests called _QPdimless - if one has to "grep" for the function that caused a problem, for example, it's a bit annoying when you get 5 hits for the same name, then you have to try to figure out which one is the one that you need to actually look at. |
Refactor to reduce code copy-paste, other minor changes
flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp | ||
---|---|---|
473 | I named the init function wrong as it returns 1 not 0 (i keep doing this!!). All the lambdas for genRuntimeAll are different than for genRuntimeAny so it would any have code outside as common - could be done but its a only few lines. |
flang/test/Transforms/simplifyintrinsics.fir | ||
---|---|---|
1246 | So, whilst you have technically fulfilled the "they are not all called the same thing", my intention with the comment was that they should each have a unique name. This could be TestAny1x10Dimless, for example. Feel free to use any scheme that is reasonably consistent, and gives different names for each test-function. |
flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp | ||
---|---|---|
163 | nit typo: of -> or | |
403 | Please verify that your changes work for the following test case: function test(a) logical*1 :: test logical*1 :: a(100) test = all(a) .or. any(a) end function test | |
425 | Please compare the logical value to zero instead of one. |
flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp | ||
---|---|---|
403 | This produces the same output when simplified as when it is not. |
flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp | ||
---|---|---|
403 | I guess it may be producing the same result. My main concern is that we are treating the argument as logical*4 in the simplified implementation whereas the actual argument is logical*1. Couldn't that cause reading past the memory area allocated for the actual array? |
flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp | ||
---|---|---|
403 | While it doesn't seem like the program was reading past boundaries, it was getting confused sometimes and return the wrong answer for very specific sized arrays, so I've put in changes to properly deal with this. |
Fix Typo
flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp | ||
---|---|---|
930 | Yes, this change was to prevent _FortranAAllocatableInitDerived as well as other 'Allocatable' intrinsics from being caught in the pass. |
FYI, the build is failing due to missing dependency: https://lab.llvm.org/buildbot/#/builders/181/builds/14278
I will merge the fix shortly.
The following code has a regression. Output from this code is now T; the output should be F.
integer z(0,5) ! integer z(0) is ok print*, any(z .ne. 1) ! should be false end
F18 clause 16.9.13 ANY (MASK) or ANY (MASK, DIM), paragraph 5, Result Value Case(i) addresses the case of a zero-size argument:
The result of ANY (MASK) has the value true if any element of MASK is true and has the value false if no elements are true or if MASK has size zero.
The test is ok if the declaration of array z is changed to z(0). The code may need a more general check for the array size.
Hi, I've put in a fix for this on this patch https://reviews.llvm.org/D143899, sorry about that.
nit typo: of -> or