This is an archive of the discontinued LLVM Phabricator instance.

Fix wrong mask generated for _mm_blendv_epi8 (BUG 24532)
AbandonedPublic

Authored by mkuper on Sep 28 2015, 4:23 AM.

Details

Summary

BUILD_VECTORtoBlendMask never updates second part of returned MaskValue and so it is always all 1s without the notion about the actual value of Lane2Cond.
This patch attempts to fix it; It breaks test/CodeGen/X86/vector-blend.ll, but the testcase itself checks for the incorrect code

Diff Detail

Event Timeline

aivchenk updated this revision to Diff 35850.Sep 28 2015, 4:23 AM
aivchenk retitled this revision from to Fix wrong mask generated for _mm_blendv_epi8 (BUG 24532).
aivchenk updated this object.
aivchenk added reviewers: mkuper, filcab, qcolombet.

Hi Alexander,

It seems like you're on track to solving the bug, but there's some details that I find weird.

Please also:
1 - Fix the test-case that's wrong
2 - Add a test-case

Adding Chandler, just to be sure there's no minute detail we might be forgetting (or for him to tell me the "undef" problem I mentioned is not a problem).

lib/Target/X86/X86ISelLowering.cpp
11105

It looks like the -1 serves as an "undef". In that case, you seem to be bailing out too early.
If Lane1Cond is 1, and Lane2Cond is undef, then we can just do what Lane1Cond says (same for when Lane1Cond is undef, but Lane2Cond is not).

I also prefer the comment above in the place where it was. It explains why the loop loops on NumElemsInLane, and not NumElems.

mkuper edited edge metadata.Oct 7 2015, 2:05 AM

I agree with Filipe.
Alexander, if you don't mind, I'll upload a fixed patch myself, this should be fairly simple.

Posted new patch as D13505.
Note that there are actually two distinct bugs in this code...

mkuper commandeered this revision.Oct 12 2015, 10:57 PM
mkuper abandoned this revision.
mkuper edited reviewers, added: aivchenk; removed: mkuper.

D13505 has been committed, so this is no longer relevant.