This is an archive of the discontinued LLVM Phabricator instance.

[X86] Allow KORTEST instruction to be used for testing if a mask is all ones
ClosedPublic

Authored by craig.topper on Jan 31 2018, 5:37 PM.

Details

Summary

The KTEST instruction sets the C flag if the result of anding both operands together is all 1s. We can use this to lower (icmp eq/ne (bitcast (vXi1 X), -1)

Diff Detail

Repository
rL LLVM

Event Timeline

RKSimon added inline comments.Feb 2 2018, 2:09 AM
test/CodeGen/X86/avx512-mask-op.ll
2839 ↗(On Diff #132299)

Fix the comment

Fix review comment.

Accidentally uploaded the patch for D42770 and D42772 together. Reverting back to just D42772

craig.topper planned changes to this revision.Feb 2 2018, 11:42 AM

Turns out KTEST doesn't actually compare with all 1s. Only KORTEST does that. KTEST sets the C flag based on the result of ANDN being 0 like ptest.

craig.topper retitled this revision from [X86] Allow KTEST instruction to be used for testing if a mask is all ones to [X86] Allow KORTEST instruction to be used for testing if a mask is all ones.

Use KORTEST instead of KTEST since it has the correct flag behavior. Use KORTEST for all 0s check too. Enable usage of KORTEST on AVX512F for v16i1. KTEST v16i1 was added with AVX512DQ but AVX512F had KTEST.

guyblank accepted this revision.Feb 7 2018, 7:06 AM
guyblank added inline comments.
test/CodeGen/X86/avx512-mask-op.ll
2839 ↗(On Diff #132731)

ktest->kortest

This revision is now accepted and ready to land.Feb 7 2018, 7:06 AM

Update comment in test so I don't forget it when the parent revision gets approved.

This revision was automatically updated to reflect the committed changes.