This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Fix crash a vector add has a 4x sext and zext operand.
ClosedPublic

Authored by craig.topper on Oct 31 2022, 12:44 PM.

Details

Summary

We can narrow one of the extends and keep the other original by
using a vwaddu.wv or vwadd.wv.

We were previously forgetting to keep the original operand and
instead took the source of its extend. This resulted in a type
mismatch that later failed with an impossible physical register copy.

To fix this I've refactored some code to maintain information about
whether the source needs to be extended at all for longer so we could
use it in materialize.

Diff Detail

Event Timeline

craig.topper created this revision.Oct 31 2022, 12:44 PM
craig.topper requested review of this revision.Oct 31 2022, 12:44 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 31 2022, 12:44 PM
qcolombet added inline comments.Oct 31 2022, 2:26 PM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
8459

That part shouldn't be needed. The getSource() should do the right thing.
I believe the reason it doesn't is because the NodeExtensionHelper got out-of-sync with the actual operand, maybe when we commute the operand of VWADD_W?

Let me check something.

craig.topper added inline comments.Oct 31 2022, 2:33 PM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
8459

I don't think it had anything to with commuting. I think we lost track of the fact that we were matching to VWADDU_W and didn't want to look through the VSEXT_VL that was on the LHS. In this function we were acting based only on the opcode of the operand and not what pattern we were matching.

qcolombet accepted this revision.Oct 31 2022, 2:45 PM

Thanks for the quick fix.

llvm/lib/Target/RISCV/RISCVISelLowering.cpp
8459

Ok well, got that wrong :).

You're right when we don't require any extension we just want to use the original value.

8738

That part of the change may not be needed to fix the issue, but I like your refactoring better anyway.
So no need to split it.

This revision is now accepted and ready to land.Oct 31 2022, 2:45 PM