File: codegenprepare-produced-address-math.ll

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 1,998,492 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (75 lines) | stat: -rw-r--r-- 2,854 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
; RUN: opt -passes='require<profile-summary>,function(codegenprepare)' -passes=load-store-vectorizer %s -S -o - | FileCheck %s
; RUN: opt                 -passes=load-store-vectorizer %s -S -o - | FileCheck %s
; RUN: opt -aa-pipeline=basic-aa -passes='function(load-store-vectorizer)' %s -S -o - | FileCheck %s

target triple = "x86_64--"

%union = type { { [4 x [4 x [4 x [16 x float]]]], [4 x [4 x [4 x [16 x float]]]], [10 x [10 x [4 x float]]] } }

@global_pointer = external unnamed_addr global { %union, [2000 x i8] }, align 4

; Function Attrs: convergent nounwind
define void @test(i32 %base) #0 {
; CHECK-LABEL: @test(
; CHECK-NOT: load i32
; CHECK: load <2 x i32>
; CHECK-NOT: load i32
entry:
  %mul331 = and i32 %base, -4
  %add350.4 = add i32 4, %mul331
  %idx351.4 = zext i32 %add350.4 to i64
  %arrayidx352.4 = getelementptr inbounds { %union, [2000 x i8] }, ptr @global_pointer, i64 0, i32 0, i32 0, i32 1, i64 0, i64 0, i64 0, i64 %idx351.4
  %add350.5 = add i32 5, %mul331
  %idx351.5 = zext i32 %add350.5 to i64
  %arrayidx352.5 = getelementptr inbounds { %union, [2000 x i8] }, ptr @global_pointer, i64 0, i32 0, i32 0, i32 1, i64 0, i64 0, i64 0, i64 %idx351.5
  %cnd = icmp ult i32 %base, 1000
  br i1 %cnd, label %loads, label %exit

loads:
  ; If and only if the loads are in a different BB from the GEPs codegenprepare
  ; would try to turn the GEPs into math, which makes LoadStoreVectorizer's job
  ; harder
  %tmp297.4 = load i32, ptr %arrayidx352.4, align 4, !tbaa !0
  %tmp297.5 = load i32, ptr %arrayidx352.5, align 4, !tbaa !0
  br label %exit

exit:
  ret void
}

; Function Attrs: convergent nounwind
define void @test.codegenprepared(i32 %base) #0 {
; CHECK-LABEL: @test.codegenprepared(
; CHECK-NOT: load i32
; CHECK: load <2 x i32>
; CHECK-NOT: load i32
entry:
  %mul331 = and i32 %base, -4
  %add350.4 = add i32 4, %mul331
  %idx351.4 = zext i32 %add350.4 to i64
  %add350.5 = add i32 5, %mul331
  %idx351.5 = zext i32 %add350.5 to i64
  %cnd = icmp ult i32 %base, 1000
  br i1 %cnd, label %loads, label %exit

loads:                                            ; preds = %entry
  %sunkaddr = mul i64 %idx351.4, 4
  %sunkaddr1 = getelementptr inbounds i8, ptr @global_pointer, i64 %sunkaddr
  %sunkaddr2 = getelementptr inbounds i8, ptr %sunkaddr1, i64 4096
  %tmp297.4 = load i32, ptr %sunkaddr2, align 4, !tbaa !0
  %sunkaddr3 = mul i64 %idx351.5, 4
  %sunkaddr4 = getelementptr inbounds i8, ptr @global_pointer, i64 %sunkaddr3
  %sunkaddr5 = getelementptr inbounds i8, ptr %sunkaddr4, i64 4096
  %tmp297.5 = load i32, ptr %sunkaddr5, align 4, !tbaa !0
  br label %exit

exit:                                             ; preds = %loads, %entry
  ret void
}

attributes #0 = { convergent nounwind }

!0 = !{!1, !1, i64 0}
!1 = !{!"float", !2, i64 0}
!2 = !{!"omnipotent char", !3, i64 0}
!3 = !{!"Simple C++ TBAA"}