This is an archive of the discontinued LLVM Phabricator instance.

[RISCV]Add Precommit test for D156685
ClosedPublic

Authored by LWenH on Aug 10 2023, 2:15 AM.

Details

Summary

Add baseline test for D156685.

In LLVM, such signed 8 bits reaminder operation will first signed extened the operands to 32 bits, and then narrow the operands to the smaller bits data type such as 16 bits during the CorrelatedValuePropagation Pass to optimize the final data storage size.

Such a signed extension operation for srem in LLVM system is to prevent the Undefined Behavior. Taking an example, -128 % -1 will lead to the Undefined Behaviour under the i8 type in LLVM IR, but this won't happen for i32, so such pattern cannot be eliminated in the platform-independent InstCombine Pass. The LLVM IR of these sext/trunc operations will be translated one by one during the RVV backend code generation process, and redundant vsetvli instructions will be inserted.

In fact, according to the RVV instruction manual, the vrem.vv instruction has already specified the final output value of this type of overflow operation. For example, the overflow operation of -128 % -1 will get 0 according to the RISC-V spec, so through this patch , I think we can optimize these redundant rvv code through the SDNode pattern match at the instruction selection phase.

Diff Detail

Event Timeline

LWenH created this revision.Aug 10 2023, 2:15 AM
LWenH requested review of this revision.Aug 10 2023, 2:15 AM
LWenH edited the summary of this revision. (Show Details)Aug 10 2023, 3:23 AM
LWenH retitled this revision from Add Precommit test for D156685 to [RISC-V]Add Precommit test for D156685.Aug 11 2023, 7:31 AM
LWenH edited the summary of this revision. (Show Details)
LWenH retitled this revision from [RISC-V]Add Precommit test for D156685 to [RISCV]Add Precommit test for D156685.Aug 12 2023, 2:23 AM
LWenH edited the summary of this revision. (Show Details)
This revision is now accepted and ready to land.Aug 13 2023, 11:43 AM
This revision was automatically updated to reflect the committed changes.