This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly][ConstantFolding] Fold fp-to-int truncation intrinsics
ClosedPublic

Authored by tlively on Aug 5 2020, 8:09 PM.

Details

Summary

Constant fold both the trapping and saturating versions of the
WebAssembly truncation intrinsics. The tests are adapted from the
WebAssembly spec tests for the corresponding instructions.

Requested in PR46982.

Diff Detail

Event Timeline

tlively created this revision.Aug 5 2020, 8:09 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 5 2020, 8:09 PM
tlively requested review of this revision.Aug 5 2020, 8:09 PM
CryZe added a subscriber: CryZe.Aug 7 2020, 1:20 AM
dschuff accepted this revision.Aug 10 2020, 12:27 PM
dschuff added inline comments.
llvm/lib/Analysis/ConstantFolding.cpp
1814

stray deletion?

This revision is now accepted and ready to land.Aug 10 2020, 12:27 PM
This revision was landed with ongoing or failed builds.Aug 10 2020, 12:40 PM
This revision was automatically updated to reflect the committed changes.

Nice! Just wondering, then are we able to fold most of our SIMD intrinsics here too?

llvm/test/Analysis/ConstantFolding/WebAssembly/trunc.ll
161

It'd probably be easier to read if there is a comment dividing the instructions that are supposed to be folded and ones that are not, such as

; Instructions below this line are not supposed to folded because they are nan or overflow/underflow

or something. The same for other functions

Yes, most of the SIMD intrinsics could be folded as well. It’s certainly on my todo list.

llvm/test/Analysis/ConstantFolding/WebAssembly/trunc.ll
161

Good idea! I will add these comments in a follow up.