File: lsr-legaladdimm.ll

package info (click to toggle)
llvm-toolchain-17 1%3A17.0.6-22
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,799,624 kB
  • sloc: cpp: 6,428,607; ansic: 1,383,196; asm: 793,408; python: 223,504; objc: 75,364; f90: 60,502; lisp: 33,869; pascal: 15,282; sh: 9,684; perl: 7,453; ml: 4,937; awk: 3,523; makefile: 2,889; javascript: 2,149; xml: 888; fortran: 619; cs: 573
file content (48 lines) | stat: -rw-r--r-- 1,617 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -mtriple=riscv32 -verify-machineinstrs < %s \
; RUN:   | FileCheck %s -check-prefix=RV32I

@a = global [4096 x i32] zeroinitializer, align 4
@b = global [4096 x i32] zeroinitializer, align 4

; This test demonstrates very slightly improved codegen in the case that
; a correct isLegalAddImmediate is implemented, thanks to LoopStrengthReduce.

define i32 @main() nounwind {
; RV32I-LABEL: main:
; RV32I:       # %bb.0: # %entry
; RV32I-NEXT:    li a0, 0
; RV32I-NEXT:    lui a1, %hi(b)
; RV32I-NEXT:    addi a1, a1, %lo(b)
; RV32I-NEXT:    lui a2, %hi(a)
; RV32I-NEXT:    addi a2, a2, %lo(a)
; RV32I-NEXT:    lui a3, 1
; RV32I-NEXT:  .LBB0_1: # %for.body
; RV32I-NEXT:    # =>This Inner Loop Header: Depth=1
; RV32I-NEXT:    addi a4, a0, -2048
; RV32I-NEXT:    sw a4, 0(a2)
; RV32I-NEXT:    sw a0, 0(a1)
; RV32I-NEXT:    addi a0, a0, 1
; RV32I-NEXT:    addi a1, a1, 4
; RV32I-NEXT:    addi a2, a2, 4
; RV32I-NEXT:    bne a0, a3, .LBB0_1
; RV32I-NEXT:  # %bb.2: # %for.end
; RV32I-NEXT:    li a0, 0
; RV32I-NEXT:    ret
entry:
  br label %for.body

for.body:
  %i.08 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
  %sub = add nsw i32 %i.08, -2048
  %arrayidx = getelementptr inbounds [4096 x i32], ptr @a, i32 0, i32 %i.08
  store i32 %sub, ptr %arrayidx, align 4
  %arrayidx1 = getelementptr inbounds [4096 x i32], ptr @b, i32 0, i32 %i.08
  store i32 %i.08, ptr %arrayidx1, align 4
  %inc = add nuw nsw i32 %i.08, 1
  %exitcond = icmp eq i32 %inc, 4096
  br i1 %exitcond, label %for.end, label %for.body

for.end:
  ret i32 0
}