This is an archive of the discontinued LLVM Phabricator instance.

[Flang] Fix for Any/All simplification to properly propogate the inital value
ClosedPublic

Authored by SBallantyne on Feb 13 2023, 3:16 AM.

Details

Summary

When rank > 1, the inital value would be lost on inner loops, leading to the wrong
value to be returned, e.g. This would return T. This patch fixes this to use the correct
inital value for all cases.

Integer :: m(0,10)
Any(m .eq 0)

Diff Detail

Event Timeline

SBallantyne created this revision.Feb 13 2023, 3:16 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptFeb 13 2023, 3:16 AM
SBallantyne requested review of this revision.Feb 13 2023, 3:16 AM

Aside from minor nit-picks, this looks good to me.

flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp
735

It's considered poor style [yes, I do this too, "do as I say, not as I do"] to introduce "other changes" with a bug-fix.

At the very least, it should be mentioned in the commit message as "Also removed some debug output code". It really doesn't hurt much to leave it in there, but don't undo this just because I said - more of "try to avoid in future".

flang/test/Transforms/simplifyintrinsics.fir
1470

Looks like you are capturing OK, but I don't see it being used later? Are those lines just removed [that's fine, but then you could just as well accept "anything" there?] - Same applies below.

SBallantyne added inline comments.Feb 13 2023, 9:26 AM
flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp
735

Fair enough, i understand that - these are just debug statements from testing that i missed before the patch went in - they shouldn't have been committed in the first place.

flang/test/Transforms/simplifyintrinsics.fir
1470

OK here is iterateVariable that determines if the next loop should go ahead, its assigned by the first value in the result statement on line 1480, the same way INIT is assigned a new value from the second value of that result statement.

vdonaldson accepted this revision.Feb 13 2023, 1:41 PM

Looks ok to me

This revision is now accepted and ready to land.Feb 13 2023, 1:41 PM

And thanks for the fix!