This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Skip implied bitmask operation in LowerShift
ClosedPublic

Authored by junparser on Feb 22 2023, 11:52 PM.

Details

Summary

This patch skips redundant explicit masks of the shift count since
it is implied inside wasm shift instruction.

Diff Detail

Event Timeline

junparser created this revision.Feb 22 2023, 11:52 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 22 2023, 11:52 PM
junparser requested review of this revision.Feb 22 2023, 11:52 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 22 2023, 11:52 PM

Minor change with comment

Thanks for the ping! Sorry this fell through the cracks.

llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
2307

Do we have tests that cover the case where the mask op is not a vector?

2311–2312

IIUC, there's no guarantee that the cast succeeds, so we have to guard against null here.

junparser added inline comments.Feb 28 2023, 6:29 PM
llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
2307

Yes, the lshr_v2i64_i32_late in ut is. Sometimes, the DAGCombiner will transform

%t = insertelement <2 x i64> undef, i64 %z, i32 0
%s = shufflevector <2 x i64> %t, <2 x i64> undef, <2 x i32> <i32 0, i32 0>
%m = and <2 x i64> %s, <i64 63, i64 63>
%a = lshr <2 x i64> %v, %m

into scalar and which saves cost of BUILD_VECTOR for constant.

Since this is common optimization, so we should handle it here.

2311–2312

sorry, lost it here. Will update.

junparser updated this revision to Diff 501355.Feb 28 2023, 6:41 PM

Address comments.

tlively accepted this revision.Mar 1 2023, 8:32 AM

Great, thank you!

This revision is now accepted and ready to land.Mar 1 2023, 8:32 AM