This is an archive of the discontinued LLVM Phabricator instance.

[SVE] No need to AND(X, 0x1) when truncating a scalable mask
AbandonedPublic

Authored by cameron.mcinally on Aug 6 2020, 11:40 AM.

Details

Summary

We're using CMPNE(X, 0) to truncate promoted fixed width masks to scalable masks. My confidence is moderate on this, but I think the preceding AND(X, 0x1) is unnecessary. I wouldn't expect a false element with tops bits set.

Did I miss something??

Diff Detail

Event Timeline

cameron.mcinally requested review of this revision.Aug 6 2020, 11:40 AM

The semantics of TRUNCATE is that it throws away the high bits. For most types, this happens implicitly, but we have to be a little more explicit here. We can't assume a the operand to a random TRUNCATE to i1 is produced by a compare operation.

If it turns out the operand to the AND is actually an all-ones/all-zeros value, we can optimize out the AND, sure.

cameron.mcinally abandoned this revision.Aug 6 2020, 11:52 AM

Ah, okay. So it's not safe to assume that the truncate to i1 is a mask. Makes sense.