[PATCH] D83159: [RISCV] Add a new codegen test

Ben Shi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 4 09:40:37 PDT 2020


benshi001 created this revision.
benshi001 added reviewers: lenary, luismarques.
Herald added subscribers: llvm-commits, evandro, apazos, sameer.abuasal, pzheng, s.egerton, Jim, benna, psnobl, jocewei, PkmX, rkruppe, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, MaskRay, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb.
Herald added a project: LLVM.
benshi001 added a comment.

This patch will show the optimization by my previous patch https://reviews.llvm.org/D83153


This case will show future optimization of add-mul DAG transform.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83159

Files:
  llvm/test/CodeGen/RISCV/addimm-mulimm.ll


Index: llvm/test/CodeGen/RISCV/addimm-mulimm.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/RISCV/addimm-mulimm.ll
@@ -0,0 +1,69 @@
+; RUN: llc -mtriple=riscv32 -mattr=+m -verify-machineinstrs < %s \
+; RUN:   | FileCheck -check-prefix=RV32IM %s
+; RUN: llc -mtriple=riscv64 -mattr=+m -verify-machineinstrs < %s \
+; RUN:   | FileCheck -check-prefix=RV64IM %s
+
+define signext i32 @add_mul_trans_1(i32 %x) {
+; RV32IM-LABEL: add_mul_trans_1
+; RV32IM:       # %bb.0:
+; RV32IM-NEXT:    addi a1, zero, 11
+; RV32IM-NEXT:    mul a0, a0, a1
+; RV32IM-NEXT:    addi a0, a0, 407
+; RV32IM-NEXT:    ret
+;
+; RV64IM-LABEL: add_mul_trans_1
+; RV64IM:       # %bb.0:
+; RV64IM-NEXT:    addi a1, zero, 11
+; RV64IM-NEXT:    mul a0, a0, a1
+; RV64IM-NEXT:    addiw a0, a0, 407
+; RV64IM-NEXT:    ret
+  %tmp0 = add i32 %x, 37
+  %tmp1 = mul i32 %tmp0, 11
+  ret i32 %tmp1
+}
+
+define signext i32 @add_mul_trans_2(i32 %x) {
+; RV32IM-LABEL: add_mul_trans_2
+; RV32IM:       # %bb.0:
+; RV32IM-NEXT:    addi a1, zero, 13
+; RV32IM-NEXT:    mul a0, a0, a1
+; RV32IM-NEXT:    lui a1, 28
+; RV32IM-NEXT:    addi a1, a1, 1701
+; RV32IM-NEXT:    add a0, a0, a1
+; RV32IM-NEXT:    ret
+;
+; RV64IM-LABEL: add_mul_trans_2
+; RV64IM:       # %bb.0:
+; RV64IM-NEXT:    addi a1, zero, 13
+; RV64IM-NEXT:    mul a0, a0, a1
+; RV64IM-NEXT:    lui a1, 28
+; RV64IM-NEXT:    addiw a1, a1, 1701
+; RV64IM-NEXT:    addw a0, a0, a1
+; RV64IM-NEXT:    ret
+  %tmp0 = add i32 %x, 8953
+  %tmp1 = mul i32 %tmp0, 13
+  ret i32 %tmp1
+}
+
+define signext i32 @add_mul_trans_3(i32 %x) {
+; RV32IM-LABEL: add_mul_trans_3
+; RV32IM:       # %bb.0:
+; RV32IM-NEXT:    addi a1, zero, 19
+; RV32IM-NEXT:    mul a0, a0, a1
+; RV32IM-NEXT:    lui a1, 9
+; RV32IM-NEXT:    addi a1, a1, 585
+; RV32IM-NEXT:    add a0, a0, a1
+; RV32IM-NEXT:    ret
+;
+; RV64IM-LABEL: add_mul_trans_3
+; RV64IM:       # %bb.0:
+; RV64IM-NEXT:    addi a1, zero, 19
+; RV64IM-NEXT:    mul a0, a0, a1
+; RV64IM-NEXT:    lui a1, 9
+; RV64IM-NEXT:    addiw a1, a1, 585
+; RV64IM-NEXT:    addw a0, a0, a1
+; RV64IM-NEXT:    ret
+  %tmp0 = add i32 %x, 1971
+  %tmp1 = mul i32 %tmp0, 19
+  ret i32 %tmp1
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83159.275504.patch
Type: text/x-patch
Size: 2200 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200704/7009f5ff/attachment-0001.bin>


More information about the llvm-commits mailing list