1
1
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2
- ; RUN: opt -opaque-pointers=0 < %s -loop-reduce -mtriple=x86_64 -S | FileCheck %s -check-prefix=INSN
3
- ; RUN: opt -opaque-pointers=0 < %s -loop-reduce -mtriple=x86_64 -lsr-insns-cost=false -S | FileCheck %s -check-prefix=REGS
4
- ; RUN: llc -opaque-pointers=0 < %s -O2 -mtriple=x86_64-unknown-unknown -lsr-insns-cost | FileCheck %s
2
+ ; RUN: opt < %s -loop-reduce -mtriple=x86_64 -S | FileCheck %s -check-prefix=INSN
3
+ ; RUN: opt < %s -loop-reduce -mtriple=x86_64 -lsr-insns-cost=false -S | FileCheck %s -check-prefix=REGS
4
+ ; RUN: llc < %s -O2 -mtriple=x86_64-unknown-unknown -lsr-insns-cost | FileCheck %s
5
5
6
6
; OPT test checks that LSR optimize compare for static counter to compare with 0.
7
7
19
19
20
20
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
21
21
22
- define void @foo (i32* nocapture readonly %x , i32* nocapture readonly %y , i32* nocapture %q ) {
22
+ define void @foo (ptr nocapture readonly %x , ptr nocapture readonly %y , ptr nocapture %q ) {
23
23
; INSN-LABEL: @foo(
24
24
; INSN-NEXT: entry:
25
- ; INSN-NEXT: [[Q1:%.*]] = bitcast i32* [[Q:%.*]] to i8*
26
- ; INSN-NEXT: [[Y3:%.*]] = bitcast i32* [[Y:%.*]] to i8*
27
- ; INSN-NEXT: [[X7:%.*]] = bitcast i32* [[X:%.*]] to i8*
28
25
; INSN-NEXT: br label [[FOR_BODY:%.*]]
29
26
; INSN: for.cond.cleanup:
30
27
; INSN-NEXT: ret void
31
28
; INSN: for.body:
32
29
; INSN-NEXT: [[LSR_IV:%.*]] = phi i64 [ [[LSR_IV_NEXT:%.*]], [[FOR_BODY]] ], [ -4096, [[ENTRY:%.*]] ]
33
- ; INSN-NEXT: [[UGLYGEP8:%.*]] = getelementptr i8, i8* [[X7]], i64 [[LSR_IV]]
34
- ; INSN-NEXT: [[UGLYGEP89:%.*]] = bitcast i8* [[UGLYGEP8]] to i32*
35
- ; INSN-NEXT: [[SCEVGEP10:%.*]] = getelementptr i32, i32* [[UGLYGEP89]], i64 1024
36
- ; INSN-NEXT: [[TMP:%.*]] = load i32, i32* [[SCEVGEP10]], align 4
37
- ; INSN-NEXT: [[UGLYGEP4:%.*]] = getelementptr i8, i8* [[Y3]], i64 [[LSR_IV]]
38
- ; INSN-NEXT: [[UGLYGEP45:%.*]] = bitcast i8* [[UGLYGEP4]] to i32*
39
- ; INSN-NEXT: [[SCEVGEP6:%.*]] = getelementptr i32, i32* [[UGLYGEP45]], i64 1024
40
- ; INSN-NEXT: [[TMP1:%.*]] = load i32, i32* [[SCEVGEP6]], align 4
30
+ ; INSN-NEXT: [[SCEVGEP4:%.*]] = getelementptr i8, ptr [[X:%.*]], i64 [[LSR_IV]]
31
+ ; INSN-NEXT: [[SCEVGEP5:%.*]] = getelementptr i8, ptr [[SCEVGEP4]], i64 4096
32
+ ; INSN-NEXT: [[TMP:%.*]] = load i32, ptr [[SCEVGEP5]], align 4
33
+ ; INSN-NEXT: [[SCEVGEP2:%.*]] = getelementptr i8, ptr [[Y:%.*]], i64 [[LSR_IV]]
34
+ ; INSN-NEXT: [[SCEVGEP3:%.*]] = getelementptr i8, ptr [[SCEVGEP2]], i64 4096
35
+ ; INSN-NEXT: [[TMP1:%.*]] = load i32, ptr [[SCEVGEP3]], align 4
41
36
; INSN-NEXT: [[ADD:%.*]] = add nsw i32 [[TMP1]], [[TMP]]
42
- ; INSN-NEXT: [[UGLYGEP:%.*]] = getelementptr i8, i8* [[Q1]], i64 [[LSR_IV]]
43
- ; INSN-NEXT: [[UGLYGEP2:%.*]] = bitcast i8* [[UGLYGEP]] to i32*
44
- ; INSN-NEXT: [[SCEVGEP:%.*]] = getelementptr i32, i32* [[UGLYGEP2]], i64 1024
45
- ; INSN-NEXT: store i32 [[ADD]], i32* [[SCEVGEP]], align 4
37
+ ; INSN-NEXT: [[SCEVGEP:%.*]] = getelementptr i8, ptr [[Q:%.*]], i64 [[LSR_IV]]
38
+ ; INSN-NEXT: [[SCEVGEP1:%.*]] = getelementptr i8, ptr [[SCEVGEP]], i64 4096
39
+ ; INSN-NEXT: store i32 [[ADD]], ptr [[SCEVGEP1]], align 4
46
40
; INSN-NEXT: [[LSR_IV_NEXT]] = add nsw i64 [[LSR_IV]], 4
47
41
; INSN-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[LSR_IV_NEXT]], 0
48
42
; INSN-NEXT: br i1 [[EXITCOND]], label [[FOR_COND_CLEANUP:%.*]], label [[FOR_BODY]]
@@ -54,13 +48,16 @@ define void @foo(i32* nocapture readonly %x, i32* nocapture readonly %y, i32* no
54
48
; REGS-NEXT: ret void
55
49
; REGS: for.body:
56
50
; REGS-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
57
- ; REGS-NEXT: [[SCEVGEP2:%.*]] = getelementptr i32, i32* [[X:%.*]], i64 [[INDVARS_IV]]
58
- ; REGS-NEXT: [[TMP:%.*]] = load i32, i32* [[SCEVGEP2]], align 4
59
- ; REGS-NEXT: [[SCEVGEP1:%.*]] = getelementptr i32, i32* [[Y:%.*]], i64 [[INDVARS_IV]]
60
- ; REGS-NEXT: [[TMP1:%.*]] = load i32, i32* [[SCEVGEP1]], align 4
51
+ ; REGS-NEXT: [[TMP0:%.*]] = shl nuw nsw i64 [[INDVARS_IV]], 2
52
+ ; REGS-NEXT: [[SCEVGEP2:%.*]] = getelementptr i8, ptr [[X:%.*]], i64 [[TMP0]]
53
+ ; REGS-NEXT: [[TMP:%.*]] = load i32, ptr [[SCEVGEP2]], align 4
54
+ ; REGS-NEXT: [[TMP1:%.*]] = shl nuw nsw i64 [[INDVARS_IV]], 2
55
+ ; REGS-NEXT: [[SCEVGEP1:%.*]] = getelementptr i8, ptr [[Y:%.*]], i64 [[TMP1]]
56
+ ; REGS-NEXT: [[TMP1:%.*]] = load i32, ptr [[SCEVGEP1]], align 4
61
57
; REGS-NEXT: [[ADD:%.*]] = add nsw i32 [[TMP1]], [[TMP]]
62
- ; REGS-NEXT: [[SCEVGEP:%.*]] = getelementptr i32, i32* [[Q:%.*]], i64 [[INDVARS_IV]]
63
- ; REGS-NEXT: store i32 [[ADD]], i32* [[SCEVGEP]], align 4
58
+ ; REGS-NEXT: [[TMP2:%.*]] = shl nuw nsw i64 [[INDVARS_IV]], 2
59
+ ; REGS-NEXT: [[SCEVGEP:%.*]] = getelementptr i8, ptr [[Q:%.*]], i64 [[TMP2]]
60
+ ; REGS-NEXT: store i32 [[ADD]], ptr [[SCEVGEP]], align 4
64
61
; REGS-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
65
62
; REGS-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[INDVARS_IV_NEXT]], 1024
66
63
; REGS-NEXT: br i1 [[EXITCOND]], label [[FOR_COND_CLEANUP:%.*]], label [[FOR_BODY]]
@@ -86,13 +83,13 @@ for.cond.cleanup: ; preds = %for.body
86
83
87
84
for.body: ; preds = %for.body, %entry
88
85
%indvars.iv = phi i64 [ 0 , %entry ], [ %indvars.iv.next , %for.body ]
89
- %arrayidx = getelementptr inbounds i32 , i32* %x , i64 %indvars.iv
90
- %tmp = load i32 , i32* %arrayidx , align 4
91
- %arrayidx2 = getelementptr inbounds i32 , i32* %y , i64 %indvars.iv
92
- %tmp1 = load i32 , i32* %arrayidx2 , align 4
86
+ %arrayidx = getelementptr inbounds i32 , ptr %x , i64 %indvars.iv
87
+ %tmp = load i32 , ptr %arrayidx , align 4
88
+ %arrayidx2 = getelementptr inbounds i32 , ptr %y , i64 %indvars.iv
89
+ %tmp1 = load i32 , ptr %arrayidx2 , align 4
93
90
%add = add nsw i32 %tmp1 , %tmp
94
- %arrayidx4 = getelementptr inbounds i32 , i32* %q , i64 %indvars.iv
95
- store i32 %add , i32* %arrayidx4 , align 4
91
+ %arrayidx4 = getelementptr inbounds i32 , ptr %q , i64 %indvars.iv
92
+ store i32 %add , ptr %arrayidx4 , align 4
96
93
%indvars.iv.next = add nuw nsw i64 %indvars.iv , 1
97
94
%exitcond = icmp eq i64 %indvars.iv.next , 1024
98
95
br i1 %exitcond , label %for.cond.cleanup , label %for.body
0 commit comments