This is an archive of the discontinued LLVM Phabricator instance.

[flang] Fix simplify intrinsic for count not checking for rank = 0 properly
ClosedPublic

Authored by SBallantyne on Jan 30 2023, 1:55 AM.

Details

Summary

Simple fix to check for rank in the same way as other intrinsics to allow
runtime count to take over when dealing with unknown dimension arrays.

Fixes #60356

Diff Detail

Event Timeline

SBallantyne created this revision.Jan 30 2023, 1:55 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJan 30 2023, 1:55 AM
SBallantyne requested review of this revision.Jan 30 2023, 1:55 AM
kiranchandramohan added inline comments.
flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp
626–628

Could you add a comment, detailing what this check means? (possibly just copying the summary here),
Could you add a test to ensure that simplify logical reduction does not happen for this case?

Add test and comment

SBallantyne marked an inline comment as done.Jan 30 2023, 2:26 AM

Looks OK except for the test checking for the wrong "Not".

flang/test/Transforms/simplifyintrinsics.fir
1239

Should be FortranACount without Dim, right? (And two lines down too)

SBallantyne marked an inline comment as done.

Fix minor issue with tests.

SBallantyne edited the summary of this revision. (Show Details)Jan 30 2023, 3:31 AM
Leporacanthicus accepted this revision.Jan 30 2023, 3:47 AM

LGTM, thanks for fixing!

This revision is now accepted and ready to land.Jan 30 2023, 3:47 AM
flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp
626

Could you check why the rank is 0 for assumed shape arrays?