|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 |
| 2 | +; RUN: llc -mtriple=riscv32 -verify-machineinstrs < %s \ |
| 3 | +; RUN: | FileCheck -check-prefix=RV32 %s |
| 4 | +; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s \ |
| 5 | +; RUN: | FileCheck -check-prefix=RV64 %s |
| 6 | + |
| 7 | +define i32 @add_shl_oneUse(i32 %x, i32 %y) nounwind { |
| 8 | +; RV32-LABEL: add_shl_oneUse: |
| 9 | +; RV32: # %bb.0: |
| 10 | +; RV32-NEXT: slli a0, a0, 3 |
| 11 | +; RV32-NEXT: add a0, a0, a1 |
| 12 | +; RV32-NEXT: addi a0, a0, 984 |
| 13 | +; RV32-NEXT: ret |
| 14 | +; |
| 15 | +; RV64-LABEL: add_shl_oneUse: |
| 16 | +; RV64: # %bb.0: |
| 17 | +; RV64-NEXT: slli a0, a0, 3 |
| 18 | +; RV64-NEXT: add a0, a0, a1 |
| 19 | +; RV64-NEXT: addiw a0, a0, 984 |
| 20 | +; RV64-NEXT: ret |
| 21 | + %add.0 = add i32 %x, 123 |
| 22 | + %shl = shl i32 %add.0, 3 |
| 23 | + %add.1 = add i32 %shl, %y |
| 24 | + ret i32 %add.1 |
| 25 | +} |
| 26 | + |
| 27 | +define void @add_shl_addmoreOneUse_in_store(ptr %array1, i32 %a, i32 %b) { |
| 28 | +; RV32-LABEL: add_shl_addmoreOneUse_in_store: |
| 29 | +; RV32: # %bb.0: # %entry |
| 30 | +; RV32-NEXT: addi a3, a1, 5 |
| 31 | +; RV32-NEXT: slli a4, a3, 2 |
| 32 | +; RV32-NEXT: add a4, a0, a4 |
| 33 | +; RV32-NEXT: sw a2, 0(a4) |
| 34 | +; RV32-NEXT: slli a1, a1, 2 |
| 35 | +; RV32-NEXT: add a0, a0, a1 |
| 36 | +; RV32-NEXT: sw a2, 24(a0) |
| 37 | +; RV32-NEXT: sw a3, 140(a0) |
| 38 | +; RV32-NEXT: ret |
| 39 | +; |
| 40 | +; RV64-LABEL: add_shl_addmoreOneUse_in_store: |
| 41 | +; RV64: # %bb.0: # %entry |
| 42 | +; RV64-NEXT: addiw a3, a1, 5 |
| 43 | +; RV64-NEXT: slli a4, a3, 2 |
| 44 | +; RV64-NEXT: add a4, a0, a4 |
| 45 | +; RV64-NEXT: sw a2, 0(a4) |
| 46 | +; RV64-NEXT: sext.w a1, a1 |
| 47 | +; RV64-NEXT: slli a1, a1, 2 |
| 48 | +; RV64-NEXT: add a0, a0, a1 |
| 49 | +; RV64-NEXT: sw a2, 24(a0) |
| 50 | +; RV64-NEXT: sw a3, 140(a0) |
| 51 | +; RV64-NEXT: ret |
| 52 | +entry: |
| 53 | + %add = add nsw i32 %a, 5 |
| 54 | + %arrayidx = getelementptr inbounds i32, ptr %array1, i32 %add |
| 55 | + store i32 %b, ptr %arrayidx |
| 56 | + %0 = getelementptr i32, ptr %array1, i32 %a |
| 57 | + %arrayidx3 = getelementptr i8, ptr %0, i32 24 |
| 58 | + store i32 %b, ptr %arrayidx3 |
| 59 | + %arrayidx5 = getelementptr i8, ptr %0, i32 140 |
| 60 | + store i32 %add, ptr %arrayidx5 |
| 61 | + ret void |
| 62 | +} |
0 commit comments