This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine][X86] Expand MOVMSK to generic IR (PR39927)
ClosedPublic

Authored by RKSimon on Apr 4 2019, 3:25 AM.

Details

Summary

First step towards removing the MOVMSK intrinsics completely - this patch expands MOVMSK to the pattern:

e.g. PMOVMSKB(v16i8 x):
%cmp = icmp slt <16 x i8> %x, zeroinitializer
%int = bitcast <16 x i8> %cmp to i16
%res = zext i16 %int to i32

Which is correctly handled by ISel and FastIsel (give or take an annoying movzx move....): https://godbolt.org/z/rkrSFW

Diff Detail

Repository
rL LLVM

Event Timeline

RKSimon created this revision.Apr 4 2019, 3:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 4 2019, 3:25 AM
RKSimon updated this revision to Diff 193681.Apr 4 2019, 3:28 AM

Fix typo in comment

spatel added inline comments.Apr 4 2019, 9:32 AM
lib/Transforms/InstCombine/InstCombineCalls.cpp
716 ↗(On Diff #193681)

<16 x i8> should be <16 x i1> as the source type for the bitcast

test/Transforms/InstCombine/X86/x86-movmsk.ll
399 ↗(On Diff #193681)

Stale comment. Could mark this a TODO, but it might cause more harm than good:

%fourbits = sext i1 %x to i4
%r = zext i4 %fourbits to i32
416 ↗(On Diff #193681)

Stale comment

RKSimon marked an inline comment as done.Apr 4 2019, 9:48 AM
RKSimon added inline comments.
test/Transforms/InstCombine/X86/x86-movmsk.ll
399 ↗(On Diff #193681)

Just to be clear - this patch doesn't affect the codegen for this: https://godbolt.org/z/dsKCrY

RKSimon updated this revision to Diff 193875.Apr 5 2019, 7:39 AM

Fixed comments

spatel accepted this revision.Apr 8 2019, 5:18 AM

LGTM

This revision is now accepted and ready to land.Apr 8 2019, 5:18 AM
This revision was automatically updated to reflect the committed changes.