This is an archive of the discontinued LLVM Phabricator instance.

[X86] Add support creating KORTEST/KTEST from icmp+bitcast+or/and
AbandonedPublic

Authored by craig.topper on Feb 1 2018, 2:14 PM.

Details

Summary

Currently we only create KTEST with the same argument twice. We don't try to find any ANDs or ORs.

This patch changes lowering to produce X86ISD::KTESTREG which represents just the flag setting behavior of KTEST/KORTEST. We now use this where we previously duplicated the operand. Isel now has patterns to look for this node with and/or to create KTEST/KORTEST. If we fail to match that, just fail back to using a KORTEST with both operands the same. KORTEST is chosen because KORTESTW is available in avx512f while KTESTW requires avx512dq.

This also updates the KORTEST intrinsic lowering to use an OR+X86ISD::KTESTREG. I'll probably look into changing the builtin to create the or+bitcast+icmp in clang and deprecrate the backend intrinsic.

Diff Detail

Event Timeline

craig.topper created this revision.Feb 1 2018, 2:14 PM
craig.topper planned changes to this revision.Feb 2 2018, 11:43 AM

Turns out this isn't how KTEST works. It was probably valid for KORTEST.

@craig.topper What happened to this?

I think this should be abandoned. We do use the C flag from KORTEST for all ones comparisons after r324577. OR+KORTEST is folded after r324580.

The one thing I can see is missing is that we don't use KTEST for an AND+bitcast+compare_with_zero. That's tracked by PR20703 after the update I just made to it.

craig.topper abandoned this revision.Jan 2 2019, 9:56 AM