This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Add matching of codegen patterns to RISCV Bit Manipulation Zbbp asm instructions
ClosedPublic

Authored by PaoloS on May 13 2020, 8:47 AM.

Details

Summary

This patch provides optimization of bit manipulation operations by enabling
the +experimental-b target feature.
It adds matching of single block patterns of instructions to specific bit-manip
instructions belonging to both the permutation and the base subsets of the
experimental B extension of RISC-V.
It adds also the correspondent codegen tests.

This patch is based on Clifford Wolf's proposal for the bit manipulation
extension of RISCV:
https://github.com/riscv/riscv-bitmanip/blob/master/bitmanip-0.92.pdf

Diff Detail

Event Timeline

PaoloS created this revision.May 13 2020, 8:47 AM
PaoloS updated this revision to Diff 276288.Jul 7 2020, 5:53 PM

Added missing pattern-matching for *w instructions.
Added tests.
Added both i32 and i64 code versions to both i32 and i64 test files.
Removed NOT labels from tests.

lewis-revill added inline comments.Jul 9 2020, 7:39 AM
llvm/lib/Target/RISCV/RISCVInstrInfoB.td
895

I'm not quite sure given the tests here how these patterns are used? Is @llvm.fshl.i32 lowered to this pattern?

PaoloS marked an inline comment as done.Jul 9 2020, 8:37 AM
PaoloS added inline comments.
llvm/lib/Target/RISCV/RISCVInstrInfoB.td
895

Precisely.

PaoloS marked an inline comment as done.Jul 9 2020, 7:35 PM
PaoloS updated this revision to Diff 277531.Jul 13 2020, 12:28 PM

Updated the test:

  • the tests have been updated from the top of all the sub-patches together so that they are exactly the same as they would be if updated with the whole final patch.
  • labels specific to the sub-extension have been added alongside the generic RISCVIB label (that activates all the sub-extensions) so that we can see how differently the patterns are matched with the specific subextension or with all of them together.
  • the tests will probably fail if run by checking out the commit of a subextension and if updated they'll change. These tests are designed to work with the final squashed patch.

Added the pattern-matching for rori and roriw.
Added the correspondent tests.

PaoloS edited the summary of this revision. (Show Details)Jul 14 2020, 6:55 AM
lewis-revill added inline comments.Jul 14 2020, 8:04 AM
llvm/lib/Target/RISCV/RISCVInstrInfoB.td
675

A little confused by this comment here, do you mean there is no pattern matching rather than there is no encoding.

llvm/test/CodeGen/RISCV/rv32Zbbp.ll
432

Nitpick: See comment on first patch regarding these extra tests.

lewis-revill accepted this revision.Jul 14 2020, 8:10 AM

See nitpicks, otherwise LGTM

This revision is now accepted and ready to land.Jul 14 2020, 8:10 AM
PaoloS marked an inline comment as done.Jul 14 2020, 8:28 AM
PaoloS added inline comments.
llvm/lib/Target/RISCV/RISCVInstrInfoB.td
675

Yeah, I mean there's no encoding at all. By consequence no pattern-matching

PaoloS marked 3 inline comments as done.Jul 14 2020, 10:25 AM
PaoloS added inline comments.
llvm/test/CodeGen/RISCV/rv32Zbbp.ll
432

I'm going to comment those.

PaoloS updated this revision to Diff 277924.Jul 14 2020, 11:41 AM
PaoloS marked an inline comment as done.

Aligned complex pattern declaration.
Clarified comment about missing 'roli' instruction.
Added comment to inefficient tests.

This revision was automatically updated to reflect the committed changes.