This is an archive of the discontinued LLVM Phabricator instance.

[RISCV][InsertVSETVLI] Using right instruction during mutate AVL of vsetvli
ClosedPublic

Authored by kito-cheng on Jan 5 2023, 7:28 AM.

Details

Summary

Fixing a crash during vsetvli insertion pass.

We have a testcase with 3 vsetvli:

  1. vsetivli zero, 2, e8, m4, ta, ma
  2. li a1, 32; vsetvli zero, a1, e8, m4, ta, mu
  3. vsetivli zero, 2, e8, m4, ta, ma

and then we trying to optimize 2nd vsetvli since the only user is vmv.x.s, so
it could mutate the AVL operand to the AVL operand of the 3rd vsetvli.
OK, so we propagate 2 to vsetvli, BUT it's vsetvli not vsetivli, so it expect a
register rather than a immediate value, so we have to update the opcode
if needed.

Diff Detail

Event Timeline

kito-cheng created this revision.Jan 5 2023, 7:28 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 5 2023, 7:28 AM
kito-cheng requested review of this revision.Jan 5 2023, 7:28 AM
reames accepted this revision.Jan 5 2023, 7:47 AM

LGTM

Sorry for the breakage, and thanks for the fix.

This revision is now accepted and ready to land.Jan 5 2023, 7:47 AM
craig.topper added inline comments.Jan 5 2023, 8:01 AM
llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
1319

I think you can drop this if. setDesc is cheap.

1320

MI.setDesc(NextMI->getDesc())?

craig.topper retitled this revision from [RISCV][InsertVSETVLI] Using rigth instruction during mutate AVL of vsetvli to [RISCV][InsertVSETVLI] Using right instruction during mutate AVL of vsetvli.Jan 5 2023, 8:38 AM
This revision was landed with ongoing or failed builds.Jan 5 2023, 8:44 AM
This revision was automatically updated to reflect the committed changes.

Just commit that without address Craig's comment, will commit a follow-up NFC patch later.

kito-cheng marked 2 inline comments as done.Jan 5 2023, 8:50 AM

Committed another NFC patch to address Craig's comment: https://reviews.llvm.org/rG7504e9a19346b33fd2e0fcdcbd43ecee3d676b86