This is an archive of the discontinued LLVM Phabricator instance.

[flang] Fix ICE for sqrt(0.0) evaluation
ClosedPublic

Authored by FruitClover on Apr 5 2022, 7:19 AM.

Details

Summary
During real range reduction to [0.5, 4) with

       SQRT(2**(2a) * x) = SQRT(2**(2a)) * SQRT(x) = 2**a * SQRT(x)

we fall into inf. recursion if IsZero() == true.

Explicitly handle SQRT(0.0) instead of additional checks during folding. Also
add helpers for +0.0/-0.0 generation to clean up a bit.

Diff Detail

Event Timeline

FruitClover created this revision.Apr 5 2022, 7:19 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptApr 5 2022, 7:19 AM
FruitClover published this revision for review.Apr 5 2022, 8:16 AM

What was the "ICE"?

flang/include/flang/Evaluate/real.h
198

MASKL(1) is clearer, since you're moving things around and can clean them up a little.

Replaced IBSET -> MASKL, updated summary details.

flang/include/flang/Evaluate/real.h
198

Updated, thanks.

FruitClover edited the summary of this revision. (Show Details)Apr 6 2022, 3:27 AM
FruitClover edited the summary of this revision. (Show Details)Apr 6 2022, 7:01 AM
klausler accepted this revision.Apr 6 2022, 7:23 AM
This revision is now accepted and ready to land.Apr 6 2022, 7:23 AM
This revision was automatically updated to reflect the committed changes.