This patch canonicalizes ZERO_EXTEND to VSELECT to allow zext to transform into a predicated instruction like add, sub or mul.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Given you want to canonicalise to vselect is it worth doing this during lowering and removing the existing zext isel pattern? that way we can be sure all instances use the same idiom? This looks like it would be equally useful for sign_extend's of predicates also?
Paul, thank you very much for the review.
I moved the code so that the canonicalisation is done during the lowering, and I removed the existing zext isel pattern.
You are right, it would be useful for sign_extend too, I'll create another patch later.
A couple of nits but it looks like the move to lowering has caused some side effects whereby we now return "Invalid cost" for predicate based llvm.experimental.vector.splice.nxv16i1. I think we're just missing some entries in AArch64TTIImpl::getCastInstrCost like
{ ISD::ZERO_EXTEND, MVT::nxv2i64, MVT::nxv2i1, 1 }, { ISD::ZERO_EXTEND, MVT::nxv4i32, MVT::nxv4i1, 1 }, { ISD::ZERO_EXTEND, MVT::nxv8i16, MVT::nxv8i1, 1 }, { ISD::ZERO_EXTEND, MVT::nxv16i8, MVT::nxv16i1, 1 },
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp | ||
---|---|---|
5570 | Can use DL, VT here as above. | |
5769–5770 | Please can you move these two lines into LowerZERO_EXTEND so all the zext lowering has the same entry point. | |
llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td | ||
515 | Does (SVEDup0) work here as a shortcut? |
llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td | ||
---|---|---|
515 | I think so, I've just replaced zext with vselect, because of the new lowering. |
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp | ||
---|---|---|
5573–5574 | This should all fit on one line now. You probably just need to rerun clang-format. |
Can use DL, VT here as above.