isOperationLegalOrCustomOrPromote returns true only if VT is other or legal
and operation action is Legal, Custom or Promote.
Permit a vector binary operation can be converted to scalar binary operation which is custom lowered with illegal type.
One of cases is i32 isn't a legal type on RV64 and its ALU operations is set to custom lowering,
so vadd for element type i32 can be converted to addw.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/Target/RISCV/RISCVISelLowering.cpp | ||
---|---|---|
1864–1865 | Can we use isOperationLegalOrCustomOrPromote? |
llvm/lib/Target/RISCV/RISCVISelLowering.cpp | ||
---|---|---|
1865 | Do we still need the || isOperationCustom(Opc, ScalarVT)? |
llvm/lib/Target/RISCV/RISCVISelLowering.cpp | ||
---|---|---|
1865 | isOperationLegalOrCustomOrPromote(Opc, ScalarVT) would return false for that i32 type (is not legal) with custom lowering operation on RV64 (ADDW, ADDIW, SUBW, ...). bool isOperationLegalOrCustomOrPromote(unsigned Op, EVT VT, bool LegalOnly = false) const { if (LegalOnly) return isOperationLegal(Op, VT); return (VT == MVT::Other || isTypeLegal(VT)) && (getOperationAction(Op, VT) == Legal || getOperationAction(Op, VT) == Custom || getOperationAction(Op, VT) == Promote); } isOperationCustom(Opc, ScalarVT) is for ADDW, ADDIW, SUBW ... can be scalarized to. |
It's not clear to me this should be restricted to i64 and i32 either. An i16 or i8 add for example doesn't require any extra code unless the result needs to be sign/zero extended.
It doesn't need to be restricted to i64 or i32 either. i32 type ALU operation on RV64 is one of cases here (Maybe is only case in all of tests we had now).
The change of this patch is if any type is not legal, but its operation action is set to custom. That we permit a vector binary operation can be converted to it. (one of cases here is vadd for element type i32 can be converted to addw).
Thanks for your feedback.
Can we use isOperationLegalOrCustomOrPromote?