mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-22 13:29:44 +00:00
One of several parallel first steps to remove the target type of pointers, replacing them with a single opaque pointer type. This adds an explicit type parameter to the gep instruction so that when the first parameter becomes an opaque pointer type, the type to gep through is still available to the instructions. * This doesn't modify gep operators, only instructions (operators will be handled separately) * Textual IR changes only. Bitcode (including upgrade) and changing the in-memory representation will be in separate changes. * geps of vectors are transformed as: getelementptr <4 x float*> %x, ... ->getelementptr float, <4 x float*> %x, ... Then, once the opaque pointer type is introduced, this will ultimately look like: getelementptr float, <4 x ptr> %x with the unambiguous interpretation that it is a vector of pointers to float. * address spaces remain on the pointer, not the type: getelementptr float addrspace(1)* %x ->getelementptr float, float addrspace(1)* %x Then, eventually: getelementptr float, ptr addrspace(1) %x Importantly, the massive amount of test case churn has been automated by same crappy python code. I had to manually update a few test cases that wouldn't fit the script's model (r228970,r229196,r229197,r229198). The python script just massages stdin and writes the result to stdout, I then wrapped that in a shell script to handle replacing files, then using the usual find+xargs to migrate all the files. update.py: import fileinput import sys import re ibrep = re.compile(r"(^.*?[^%\w]getelementptr inbounds )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))") normrep = re.compile( r"(^.*?[^%\w]getelementptr )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))") def conv(match, line): if not match: return line line = match.groups()[0] if len(match.groups()[5]) == 0: line += match.groups()[2] line += match.groups()[3] line += ", " line += match.groups()[1] line += "\n" return line for line in sys.stdin: if line.find("getelementptr ") == line.find("getelementptr inbounds"): if line.find("getelementptr inbounds") != line.find("getelementptr inbounds ("): line = conv(re.match(ibrep, line), line) elif line.find("getelementptr ") != line.find("getelementptr ("): line = conv(re.match(normrep, line), line) sys.stdout.write(line) apply.sh: for name in "$@" do python3 `dirname "$0"`/update.py < "$name" > "$name.tmp" && mv "$name.tmp" "$name" rm -f "$name.tmp" done The actual commands: From llvm/src: find test/ -name *.ll | xargs ./apply.sh From llvm/src/tools/clang: find test/ -name *.mm -o -name *.m -o -name *.cpp -o -name *.c | xargs -I '{}' ../../apply.sh "{}" From llvm/src/tools/polly: find test/ -name *.ll | xargs ./apply.sh After that, check-all (with llvm, clang, clang-tools-extra, lld, compiler-rt, and polly all checked out). The extra 'rm' in the apply.sh script is due to a few files in clang's test suite using interesting unicode stuff that my python script was throwing exceptions on. None of those files needed to be migrated, so it seemed sufficient to ignore those cases. Reviewers: rafael, dexonsmith, grosser Differential Revision: http://reviews.llvm.org/D7636 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230786 91177308-0d34-0410-b5e6-96231b3b80d8
94 lines
5.1 KiB
LLVM
94 lines
5.1 KiB
LLVM
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
|
|
target triple = "x86_64-unknown-linux-gnu"
|
|
; RUN: opt < %s -bb-vectorize -bb-vectorize-req-chain-depth=3 -bb-vectorize-ignore-target-info -instcombine -gvn -S | FileCheck %s
|
|
; RUN: opt < %s -basicaa -loop-unroll -unroll-threshold=45 -unroll-allow-partial -bb-vectorize -bb-vectorize-req-chain-depth=3 -bb-vectorize-ignore-target-info -instcombine -gvn -S | FileCheck %s -check-prefix=CHECK-UNRL
|
|
; The second check covers the use of alias analysis (with loop unrolling).
|
|
|
|
define void @test1(double* noalias %out, double* noalias %in1, double* noalias %in2) nounwind uwtable {
|
|
entry:
|
|
br label %for.body
|
|
; CHECK-LABEL: @test1(
|
|
; CHECK-UNRL-LABEL: @test1(
|
|
|
|
for.body: ; preds = %for.body, %entry
|
|
%indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
|
|
%arrayidx = getelementptr inbounds double, double* %in1, i64 %indvars.iv
|
|
%0 = load double* %arrayidx, align 8
|
|
%arrayidx2 = getelementptr inbounds double, double* %in2, i64 %indvars.iv
|
|
%1 = load double* %arrayidx2, align 8
|
|
%mul = fmul double %0, %0
|
|
%mul3 = fmul double %0, %1
|
|
%add = fadd double %mul, %mul3
|
|
%add4 = fadd double %1, %1
|
|
%add5 = fadd double %add4, %0
|
|
%mul6 = fmul double %0, %add5
|
|
%add7 = fadd double %add, %mul6
|
|
%mul8 = fmul double %1, %1
|
|
%add9 = fadd double %0, %0
|
|
%add10 = fadd double %add9, %0
|
|
%mul11 = fmul double %mul8, %add10
|
|
%add12 = fadd double %add7, %mul11
|
|
%arrayidx14 = getelementptr inbounds double, double* %out, i64 %indvars.iv
|
|
store double %add12, double* %arrayidx14, align 8
|
|
%indvars.iv.next = add i64 %indvars.iv, 1
|
|
%lftr.wideiv = trunc i64 %indvars.iv.next to i32
|
|
%exitcond = icmp eq i32 %lftr.wideiv, 10
|
|
br i1 %exitcond, label %for.end, label %for.body
|
|
; CHECK: %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
|
|
; CHECK: %arrayidx = getelementptr inbounds double, double* %in1, i64 %indvars.iv
|
|
; CHECK: %0 = load double* %arrayidx, align 8
|
|
; CHECK: %arrayidx2 = getelementptr inbounds double, double* %in2, i64 %indvars.iv
|
|
; CHECK: %1 = load double* %arrayidx2, align 8
|
|
; CHECK: %mul = fmul double %0, %0
|
|
; CHECK: %mul3 = fmul double %0, %1
|
|
; CHECK: %add = fadd double %mul, %mul3
|
|
; CHECK: %mul8 = fmul double %1, %1
|
|
; CHECK: %add4.v.i1.1 = insertelement <2 x double> undef, double %1, i32 0
|
|
; CHECK: %add4.v.i1.2 = insertelement <2 x double> %add4.v.i1.1, double %0, i32 1
|
|
; CHECK: %add4 = fadd <2 x double> %add4.v.i1.2, %add4.v.i1.2
|
|
; CHECK: %add5.v.i1.1 = insertelement <2 x double> undef, double %0, i32 0
|
|
; CHECK: %add5.v.i1.2 = insertelement <2 x double> %add5.v.i1.1, double %0, i32 1
|
|
; CHECK: %add5 = fadd <2 x double> %add4, %add5.v.i1.2
|
|
; CHECK: %mul6.v.i0.2 = insertelement <2 x double> %add5.v.i1.1, double %mul8, i32 1
|
|
; CHECK: %mul6 = fmul <2 x double> %mul6.v.i0.2, %add5
|
|
; CHECK: %mul6.v.r1 = extractelement <2 x double> %mul6, i32 0
|
|
; CHECK: %mul6.v.r2 = extractelement <2 x double> %mul6, i32 1
|
|
; CHECK: %add7 = fadd double %add, %mul6.v.r1
|
|
; CHECK: %add12 = fadd double %add7, %mul6.v.r2
|
|
; CHECK: %arrayidx14 = getelementptr inbounds double, double* %out, i64 %indvars.iv
|
|
; CHECK: store double %add12, double* %arrayidx14, align 8
|
|
; CHECK: %indvars.iv.next = add i64 %indvars.iv, 1
|
|
; CHECK: %lftr.wideiv = trunc i64 %indvars.iv.next to i32
|
|
; CHECK: %exitcond = icmp eq i32 %lftr.wideiv, 10
|
|
; CHECK: br i1 %exitcond, label %for.end, label %for.body
|
|
; CHECK-UNRL: %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next.1, %for.body ]
|
|
; CHECK-UNRL: %arrayidx = getelementptr inbounds double, double* %in1, i64 %indvars.iv
|
|
; CHECK-UNRL: %0 = bitcast double* %arrayidx to <2 x double>*
|
|
; CHECK-UNRL: %arrayidx2 = getelementptr inbounds double, double* %in2, i64 %indvars.iv
|
|
; CHECK-UNRL: %1 = bitcast double* %arrayidx2 to <2 x double>*
|
|
; CHECK-UNRL: %arrayidx14 = getelementptr inbounds double, double* %out, i64 %indvars.iv
|
|
; CHECK-UNRL: %2 = load <2 x double>* %0, align 8
|
|
; CHECK-UNRL: %3 = load <2 x double>* %1, align 8
|
|
; CHECK-UNRL: %mul = fmul <2 x double> %2, %2
|
|
; CHECK-UNRL: %mul3 = fmul <2 x double> %2, %3
|
|
; CHECK-UNRL: %add = fadd <2 x double> %mul, %mul3
|
|
; CHECK-UNRL: %add4 = fadd <2 x double> %3, %3
|
|
; CHECK-UNRL: %add5 = fadd <2 x double> %add4, %2
|
|
; CHECK-UNRL: %mul6 = fmul <2 x double> %2, %add5
|
|
; CHECK-UNRL: %add7 = fadd <2 x double> %add, %mul6
|
|
; CHECK-UNRL: %mul8 = fmul <2 x double> %3, %3
|
|
; CHECK-UNRL: %add9 = fadd <2 x double> %2, %2
|
|
; CHECK-UNRL: %add10 = fadd <2 x double> %add9, %2
|
|
; CHECK-UNRL: %mul11 = fmul <2 x double> %mul8, %add10
|
|
; CHECK-UNRL: %add12 = fadd <2 x double> %add7, %mul11
|
|
; CHECK-UNRL: %4 = bitcast double* %arrayidx14 to <2 x double>*
|
|
; CHECK-UNRL: store <2 x double> %add12, <2 x double>* %4, align 8
|
|
; CHECK-UNRL: %indvars.iv.next.1 = add nsw i64 %indvars.iv, 2
|
|
; CHECK-UNRL: %lftr.wideiv.1 = trunc i64 %indvars.iv.next.1 to i32
|
|
; CHECK-UNRL: %exitcond.1 = icmp eq i32 %lftr.wideiv.1, 10
|
|
; CHECK-UNRL: br i1 %exitcond.1, label %for.end, label %for.body
|
|
|
|
for.end: ; preds = %for.body
|
|
ret void
|
|
}
|