This is an archive of the discontinued LLVM Phabricator instance.

[LSR][RISCV] Improve test coverage for LSR in RISC-V
Needs RevisionPublic

Authored by eopXD on Apr 9 2022, 11:58 AM.

Details

Reviewers
joshua-arch1
asb
craig.topper
jrtc27
frasercrmck
reames
Group Reviewers
Restricted Project
Summary

Patch like D116735 suggest improvement for LSR, but we currently
don't have test coverage for this under RISCV. Testcases are modified
from CodeGen/X86/cases loop-strength-reduce*.ll

Diff Detail

Event Timeline

eopXD created this revision.Apr 9 2022, 11:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 9 2022, 11:58 AM
eopXD requested review of this revision.Apr 9 2022, 11:58 AM
eopXD updated this revision to Diff 421750.Apr 9 2022, 11:59 AM

Update code.

eopXD edited the summary of this revision. (Show Details)Apr 9 2022, 12:00 PM
eopXD added reviewers: jrtc27, frasercrmck.
eopXD edited the summary of this revision. (Show Details)Apr 9 2022, 12:03 PM
craig.topper added inline comments.Apr 9 2022, 8:09 PM
llvm/test/CodeGen/RISCV/loop-strength-reduce.ll
7

Can we add signext attributes to the i32 arguments to match the ABI for rv64 and remove some extra sext.w

jrtc27 added a comment.Apr 9 2022, 9:10 PM

The test case file names are uninformative, and having both reduce-2/3 and reduce2/3 doesn't seem like a good idea

eopXD updated this revision to Diff 421798.Apr 10 2022, 11:18 AM

Update code.

  • Delete peephole optimization testcases of X86
  • Delete duplicate test case (since we are checking line-by-line)
  • Rename test cases
  • Add some descriptions into test cases
eopXD marked an inline comment as done.Apr 10 2022, 11:20 AM
eopXD added a comment.Apr 16 2022, 3:20 AM

gentle ping.

craig.topper added inline comments.Apr 18 2022, 1:09 PM
llvm/test/CodeGen/RISCV/loop-strength-reduce-add-cheaper-than-mul.ll
74 ↗(On Diff #421798)

Please use the -mattr=+m to avoid this libcall

llvm/test/CodeGen/RISCV/loop-strength-reduce-ivusers.ll
48 ↗(On Diff #421798)

Why is this loop substantially simpler than the RV32 version? I suspect LSR doesn't run on RV64, but that means that LSR is making the RV32 loop worse than we would get without it?

57 ↗(On Diff #421798)

Are these branch on true needed?

74 ↗(On Diff #421798)

This load is dead. This whole test looks overly reduced.

eopXD updated this revision to Diff 427926.May 8 2022, 4:49 AM
eopXD marked 3 inline comments as done.

Update testcase:

  • add -mattr=+m for loop-strength-reduce-add-cheaper-than-mul.ll
  • run simplifycfg for loop-strength-reduce-ivusers.ll
llvm/test/CodeGen/RISCV/loop-strength-reduce-ivusers.ll
48 ↗(On Diff #421798)

Yes. LSR is generating running on RV32 and generating worse code.

57 ↗(On Diff #421798)

Updated test case with simplifycfg

74 ↗(On Diff #421798)

Updated test case with simplifycfg

eopXD added a subscriber: reames.May 12 2022, 10:47 AM

@reames
Since you mentioned the LSR deficiency in your public note.
You may be interested with these new test cases for the RISC-V backend.

eopXD edited the summary of this revision. (Show Details)May 12 2022, 10:48 AM
eopXD added a reviewer: Restricted Project.May 19 2022, 11:35 PM
eopXD updated this revision to Diff 430894.May 20 2022, 12:18 AM

Rebase to latest main.

reames requested changes to this revision.May 20 2022, 10:25 AM

I split off, cleaned up, and landed two of these in 923831e. It was easier to do the cleanup myself than explain what needed done.

The two I left out make heavy use of struct types. In addition to the style of simplification done in the landed ones, we should also maximally simplify the struct types involved. Want to take a shot at that? I ran out of time for this at the moment.

This revision now requires changes to proceed.May 20 2022, 10:25 AM