This is an archive of the discontinued LLVM Phabricator instance.

[X86] Add a DAG combine to transform (add (zext (vXi1 X)), Y) -> (sub Y, (sext (vXi1 X))) with avx512
AbandonedPublic

Authored by craig.topper on Sep 27 2019, 3:33 PM.

Details

Summary

With AVX512, we can more efficiently sign extend vXi1 to vector registers. Zero extending requires doing a sign extend and then shifting right by width-1 or anding with 1.

We have a similar combine from sub->add in generic DAG combine, but replicating that caused possible regressions on other targets. I've limited this to only cases where bool vectors are legal to avoid some other regressions on X86.

Diff Detail

Event Timeline

craig.topper created this revision.Sep 27 2019, 3:33 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 27 2019, 3:33 PM
Herald added a subscriber: hiraditya. · View Herald Transcript

This is already in trunk with:
rL373136
...so call this post-commit review? :)

Instead of checking for AVX512, would it be better to check that the bool vector type is actually legal as the code comment specifies? Eg:

TLI.isTypeLegal(Op0.getOperand(0).getValueType())