This is an archive of the discontinued LLVM Phabricator instance.

[X86][AVX512] Fix PR31515 - Do not flip vselect condition if it's not a vXi1 mask
ClosedPublic

Authored by eladcohen on Jan 11 2017, 2:29 AM.

Details

Summary

r289653 added a case where

vselect <cond> <vector1> <all-zeros>

is transformed to:

vselect xor(cond, DAG.getConstant(1, DL, Cond.getValueType())) <all-zeros> <vector1>

This was not aimed to catch cases where Cond is not a vXi1 mask but it does (e.g. happens on KNL for select <16 x i1>). Moreover, when Cond type is VxiN (N > 1) then xor(cond, DAG.getConstant(1, DL, Cond.getValueType())) != NOT(cond).
This patch changes the above to xor with allones, and avoids entering the case for non-mask Conds.

Diff Detail

Event Timeline

eladcohen updated this revision to Diff 83929.Jan 11 2017, 2:29 AM
eladcohen retitled this revision from to [X86][AVX512] Fix PR31515 - Do not flip vselect condition if it's not a vXi1 mask.
eladcohen updated this object.
eladcohen added subscribers: llvm-commits, zvi, aymanmus and 2 others.
craig.topper added inline comments.Jan 11 2017, 11:58 AM
lib/Target/X86/X86ISelLowering.cpp
28754

Why do we need getScalarSizeInBits() if we already know its i1?

eladcohen added inline comments.Jan 11 2017, 9:56 PM
lib/Target/X86/X86ISelLowering.cpp
28754

I thought it will be better to keep the code correct for any vector type just in case we decide one day to remove/change the

CondVT.getVectorElementType() == MVT::i1

condition.

craig.topper accepted this revision.Jan 11 2017, 10:20 PM
craig.topper edited edge metadata.

LGTM

This revision is now accepted and ready to land.Jan 11 2017, 10:20 PM

Thanks for the review!
Committed in r291745.

eladcohen closed this revision.Jan 11 2017, 11:06 PM