This is an archive of the discontinued LLVM Phabricator instance.

InstSimplify: Handle basic folds for frexp
ClosedPublic

Authored by arsenm on Jul 17 2023, 3:55 AM.

Details

Summary

Handle constant folding and idempotent folding. Not sure
this is an appropriate use of undef for the inf/nan case. The
C version says the second result is "unspecified". The AMDGPU
instruction returns 0.

Diff Detail

Event Timeline

arsenm created this revision.Jul 17 2023, 3:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 17 2023, 3:55 AM
arsenm requested review of this revision.Jul 17 2023, 3:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 17 2023, 3:55 AM
Herald added a subscriber: wdng. · View Herald Transcript
nlopes added inline comments.Jul 17 2023, 4:04 AM
llvm/lib/Analysis/ConstantFolding.cpp
3314

I suggest we use 0 here to avoid adding another use of undef. Also, it's unclear if undef is ok or if we would need freeze poison.

The rest, LGTM!

arsenm updated this revision to Diff 540959.Jul 17 2023, 5:06 AM

Use 0 instead of undef, fix breaking overflow intrinsic handling

arsenm marked an inline comment as done.Jul 17 2023, 5:06 AM

Use 0 instead of undef, fix breaking overflow intrinsic handling

APFloat actually uses INT_MIN and INT_MAX, but 0 seems better? I don't know why this isn't just specified to return the maximum exponent

nlopes accepted this revision.Jul 17 2023, 9:20 AM
This revision is now accepted and ready to land.Jul 17 2023, 9:20 AM