mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-31 12:30:06 +00:00
Essentially the same as the GEP change in r230786. A similar migration script can be used to update test cases, though a few more test case improvements/changes were required this time around: (r229269-r229278) import fileinput import sys import re pat = re.compile(r"((?:=|:|^)\s*load (?:atomic )?(?:volatile )?(.*?))(| addrspace\(\d+\) *)\*($| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$)") for line in sys.stdin: sys.stdout.write(re.sub(pat, r"\1, \2\3*\4", line)) Reviewers: rafael, dexonsmith, grosser Differential Revision: http://reviews.llvm.org/D7649 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230794 91177308-0d34-0410-b5e6-96231b3b80d8
87 lines
2.6 KiB
LLVM
87 lines
2.6 KiB
LLVM
; RUN: llc -march=hexagon -mcpu=hexagonv4 < %s | FileCheck %s
|
|
; Check that we remove the compare and induction variable instructions
|
|
; after generating hardware loops.
|
|
; Bug 6685.
|
|
|
|
; CHECK: loop0
|
|
; CHECK-NOT: r{{[0-9]+}}{{.}}={{.}}add(r{{[0-9]+}},{{.}}#-1)
|
|
; CHECK-NOT: cmp.eq
|
|
; CHECK: endloop0
|
|
|
|
define i32 @test1(i32* nocapture %b, i32 %n) nounwind readonly {
|
|
entry:
|
|
%cmp1 = icmp sgt i32 %n, 0
|
|
br i1 %cmp1, label %for.body.preheader, label %for.end
|
|
|
|
for.body.preheader:
|
|
br label %for.body
|
|
|
|
for.body: ; preds = %for.body.preheader, %for.body
|
|
%sum.03 = phi i32 [ %add, %for.body ], [ 0, %for.body.preheader ]
|
|
%arrayidx.phi = phi i32* [ %arrayidx.inc, %for.body ], [ %b, %for.body.preheader ]
|
|
%i.02 = phi i32 [ %inc, %for.body ], [ 0, %for.body.preheader ]
|
|
%0 = load i32, i32* %arrayidx.phi, align 4
|
|
%add = add nsw i32 %0, %sum.03
|
|
%inc = add nsw i32 %i.02, 1
|
|
%exitcond = icmp eq i32 %inc, %n
|
|
%arrayidx.inc = getelementptr i32, i32* %arrayidx.phi, i32 1
|
|
br i1 %exitcond, label %for.end.loopexit, label %for.body
|
|
|
|
for.end.loopexit:
|
|
br label %for.end
|
|
|
|
for.end:
|
|
%sum.0.lcssa = phi i32 [ 0, %entry ], [ %add, %for.end.loopexit ]
|
|
ret i32 %sum.0.lcssa
|
|
}
|
|
|
|
; This test checks that that initial loop count value is removed.
|
|
; CHECK-NOT: ={{.}}#40
|
|
; CHECK: loop0
|
|
; CHECK-NOT: r{{[0-9]+}}{{.}}={{.}}add(r{{[0-9]+}},{{.}}#-1)
|
|
; CHECK-NOT: cmp.eq
|
|
; CHECK: endloop0
|
|
|
|
define i32 @test2(i32* nocapture %b) nounwind readonly {
|
|
entry:
|
|
br label %for.body
|
|
|
|
for.body:
|
|
%sum.02 = phi i32 [ 0, %entry ], [ %add, %for.body ]
|
|
%arrayidx.phi = phi i32* [ %b, %entry ], [ %arrayidx.inc, %for.body ]
|
|
%i.01 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
|
|
%0 = load i32, i32* %arrayidx.phi, align 4
|
|
%add = add nsw i32 %0, %sum.02
|
|
%inc = add nsw i32 %i.01, 1
|
|
%exitcond = icmp eq i32 %inc, 40
|
|
%arrayidx.inc = getelementptr i32, i32* %arrayidx.phi, i32 1
|
|
br i1 %exitcond, label %for.end, label %for.body
|
|
|
|
for.end:
|
|
ret i32 %add
|
|
}
|
|
|
|
; This test checks that we don't remove the induction variable since it's used.
|
|
; CHECK: loop0
|
|
; CHECK: r{{[0-9]+}}{{.}}={{.}}add(r{{[0-9]+}},{{.}}#1)
|
|
; CHECK-NOT: cmp.eq
|
|
; CHECK: endloop0
|
|
define i32 @test3(i32* nocapture %b) nounwind {
|
|
entry:
|
|
br label %for.body
|
|
|
|
for.body:
|
|
%arrayidx.phi = phi i32* [ %b, %entry ], [ %arrayidx.inc, %for.body ]
|
|
%i.01 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
|
|
store i32 %i.01, i32* %arrayidx.phi, align 4
|
|
%inc = add nsw i32 %i.01, 1
|
|
%exitcond = icmp eq i32 %inc, 40
|
|
%arrayidx.inc = getelementptr i32, i32* %arrayidx.phi, i32 1
|
|
br i1 %exitcond, label %for.end, label %for.body
|
|
|
|
for.end:
|
|
ret i32 0
|
|
}
|
|
|
|
|