This is an archive of the discontinued LLVM Phabricator instance.

[LegalizeTypes][RISCV][NFC] Modify assert in PromoteIntRes_STEP_VECTOR and add some tests for RISCV
ClosedPublic

Authored by Jimerlife on Jun 15 2022, 11:12 PM.

Details

Summary
  1. Modify assert in PromoteIntRes_STEP_VECTOR.
  2. Add promote step_vector test for RISCV.

Diff Detail

Event Timeline

Jimerlife created this revision.Jun 15 2022, 11:12 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 15 2022, 11:12 PM
Jimerlife requested review of this revision.Jun 15 2022, 11:12 PM
craig.topper added inline comments.Jun 15 2022, 11:49 PM
llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
5280–5281

Why this change? llvm.stepvector intrinsic works for fixed vectors.

llvm/test/CodeGen/RISCV/rvv/vreductions-fp-vp.ll
318 ↗(On Diff #437432)

The rest of this patch involve stepvector, but this doesn't. Unless I'm missing something this should be a different patch.

Jimerlife added inline comments.Jun 16 2022, 12:33 AM
llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
5280–5281

Yes, llvm.stepvector intrinsic works for fixed vectors, but ISD::STEP_VECTOR is only work for scalable vector. I'm not sure my understanding is right?

Jimerlife edited the summary of this revision. (Show Details)
Jimerlife added inline comments.
llvm/test/CodeGen/RISCV/rvv/vreductions-fp-vp.ll
318 ↗(On Diff #437432)

Removed this change.

david-arm added inline comments.Jun 16 2022, 1:38 AM
llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
5280–5281

I agree with @craig.topper. I don't understand why we're changing the assert here. This should work for fixed vectors too so we should be asserting that the result is a vector, i.e. either fixed-width or scalable.

Jimerlife added inline comments.Jun 16 2022, 2:24 AM
llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
5280–5281

If call <vscale x 4 x i15> @llvm.experimental.stepvector.nxv4i15(), it generated nxv4i15 = step_vector node.
But if call <4 x i15> @llvm.experimental.stepvector.v4i15(), it generated v4i15 = build_vector node.

My understand is that fixed vectors cann't generate node like v4i15 = step_vector.
So, only scalable vector will go through PromoteIntRes_STEP_VECTOR if it need to promote.
This is right? @craig.topper @david-arm

frasercrmck added inline comments.Jun 16 2022, 2:28 AM
llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
5280–5281

That's my understanding, yes - we don't generate ISD::STEP_VECTOR for fixed-length vector types. Take a look at SelectionDAG::getStepVector's implementation. I assume that's done for canonicalization purposes.

david-arm added inline comments.Jun 16 2022, 2:49 AM
llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
5280–5281

My apologies @Jimerlife, you are absolutely right! I was thinking about the SelectionDAG::getStepVector interface, but this only returns STEP_VECTOR for scalable vectors. In fact, the ISD node states:

/// STEP_VECTOR(IMM) - Returns a scalable vector whose lanes are comprised
/// of a linear sequence of unsigned values starting from 0 with a step of
/// IMM, where IMM must be a TargetConstant with type equal to the vector
/// element type. The arithmetic is performed modulo the bitwidth of the
/// element.
///
/// The operation does not support returning fixed-width vectors or
/// non-constant operands.
STEP_VECTOR,
This revision is now accepted and ready to land.Jun 16 2022, 8:04 AM
This revision was landed with ongoing or failed builds.Jun 16 2022, 7:28 PM
This revision was automatically updated to reflect the committed changes.