Imported Upstream version 6.10.0.49

Former-commit-id: 1d6753294b2993e1fbf92de9366bb9544db4189b
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2020-01-16 16:38:04 +00:00
parent d94e79959b
commit 468663ddbb
48518 changed files with 2789335 additions and 61176 deletions

View File

@ -0,0 +1,32 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -instsimplify -S | FileCheck %s
; Test constant fold of constant expression GEP used by ptrtoint (the
; "offsetof-like expression" case).
; This used to hit an assert due to not supporting vectors in
; llvm::ConstantFoldCastInstruction when handling ptrtoint.
define <2 x i16> @test1() {
; CHECK-LABEL: @test1(
; CHECK-NEXT: entry:
; CHECK-NEXT: ret <2 x i16> ptrtoint (<2 x i32*> getelementptr ([10 x i32], [10 x i32]* null, <2 x i64> zeroinitializer, <2 x i64> <i64 5, i64 7>) to <2 x i16>)
;
entry:
%gep = getelementptr inbounds [10 x i32], [10 x i32]* null, i16 0, <2 x i16> <i16 5, i16 7>
%vec = ptrtoint <2 x i32*> %gep to <2 x i16>
ret <2 x i16> %vec
}
; Test constant fold of constant expression GEP used by ptrtoint (the
; "sizeof-like expression" case).
; This used to hit an assert due to not supporting vectors in
; llvm::ConstantFoldCastInstruction when handling ptrtoint.
define <2 x i16> @test2() {
; CHECK-LABEL: @test2(
; CHECK-NEXT: entry:
; CHECK-NEXT: ret <2 x i16> ptrtoint (<2 x i32*> getelementptr (i32, i32* null, <2 x i64> <i64 5, i64 7>) to <2 x i16>)
;
entry:
%gep = getelementptr i32, i32* null, <2 x i16> <i16 5, i16 7>
%vec = ptrtoint <2 x i32*> %gep to <2 x i16>
ret <2 x i16> %vec
}

View File

@ -0,0 +1,52 @@
; RUN: opt -gvn -S -o - %s | FileCheck %s
; RUN: opt -newgvn -S -o - %s | FileCheck %s
; Test that the constantfolding getelementptr computation results in
; j[5][4][1] (j+239)
; and not [1][4][4][1] (#449) which is an incorrect out-of-range error
target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
target triple = "armv7-none-eabi"
@f = local_unnamed_addr global i32 2, align 4
@t6 = local_unnamed_addr global i32 1, align 4
@j = local_unnamed_addr global [6 x [6 x [7 x i8]]] [[6 x [7 x i8]] [[7 x i8] c"\06\00\00\00\00\00\00", [7 x i8] zeroinitializer, [7 x i8] zeroinitializer, [7 x i8] zeroinitializer, [7 x i8] zeroinitializer, [7 x i8] zeroinitializer], [6 x [7 x i8]] zeroinitializer, [6 x [7 x i8]] zeroinitializer, [6 x [7 x i8]] zeroinitializer, [6 x [7 x i8]] zeroinitializer, [6 x [7 x i8]] zeroinitializer], align 1
@p = internal global i64 0, align 8
@y = local_unnamed_addr global i64* @p, align 4
@b = internal unnamed_addr global i32 0, align 4
@h = common local_unnamed_addr global i16 0, align 2
@a = common local_unnamed_addr global i32 0, align 4
@k = common local_unnamed_addr global i32 0, align 4
@t11 = common local_unnamed_addr global i32 0, align 4
; Function Attrs: nounwind
define i32 @main() local_unnamed_addr {
entry:
%0 = load i32, i32* @t6, align 4
%inc = add nsw i32 %0, 1
store i32 %inc, i32* @t6, align 4
store i16 4, i16* @h, align 2
%1 = load i32, i32* @a, align 4
%conv = trunc i32 %1 to i8
store i32 1, i32* @f, align 4
%2 = load i64, i64* @p, align 8
%cmp4 = icmp slt i64 %2, 2
%conv6 = zext i1 %cmp4 to i8
%3 = load i16, i16* @h, align 2
%conv7 = sext i16 %3 to i32
%add = add nsw i32 %conv7, 1
%f.promoted = load i32, i32* @f, align 4
%4 = mul i32 %conv7, 7
%5 = add i32 %4, 5
%6 = sub i32 -1, %f.promoted
%7 = icmp sgt i32 %6, -2
%smax = select i1 %7, i32 %6, i32 -2
%8 = sub i32 6, %smax
%scevgep = getelementptr [6 x [6 x [7 x i8]]], [6 x [6 x [7 x i8]]]* @j, i32 0, i32 0, i32 %5, i32 %8
%9 = add i32 %f.promoted, %smax
%10 = add i32 %9, 2
call void @llvm.memset.p0i8.i32(i8* %scevgep, i8 %conv6, i32 %10, i32 1, i1 false)
; CHECK: call void @llvm.memset.p0i8.i32(i8* getelementptr inbounds ([6 x [6 x [7 x i8]]], [6 x [6 x [7 x i8]]]* @j, i32 0, i{{32|64}} 5, i{{32|64}} 4, i32 1), i8 %conv6, i32 1, i32 1, i1 false)
; CHECK-NOT: call void @llvm.memset.p0i8.i32(i8* getelementptr ([6 x [6 x [7 x i8]]], [6 x [6 x [7 x i8]]]* @j, i64 1, i64 4, i64 4, i32 1)
ret i32 0
}
; Function Attrs: argmemonly nounwind
declare void @llvm.memset.p0i8.i32(i8* nocapture writeonly, i8, i32, i32, i1)

View File

@ -0,0 +1,30 @@
; RUN: opt -instcombine -S -o - %s | FileCheck %s
; Tests that we preserve the inrange attribute on indices where possible.
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
%struct.A = type { i32 (...)** }
@vt = external global [3 x i8*]
; CHECK: define i32 (...)* @f0()
define i32 (...)* @f0() {
; CHECK-NEXT: load i32 (...)*, i32 (...)** bitcast (i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @vt, inrange i64 0, i64 2) to i32 (...)**)
%load = load i32 (...)*, i32 (...)** getelementptr (i32 (...)*, i32 (...)** bitcast (i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @vt, inrange i64 0, i64 1) to i32 (...)**), i64 1)
ret i32 (...)* %load
}
; CHECK: define i32 (...)* @f1()
define i32 (...)* @f1() {
; CHECK-NEXT: load i32 (...)*, i32 (...)** bitcast (i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @vt, i64 0, i64 2) to i32 (...)**)
%load = load i32 (...)*, i32 (...)** getelementptr (i32 (...)*, i32 (...)** bitcast (i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @vt, i64 0, inrange i64 1) to i32 (...)**), i64 1)
ret i32 (...)* %load
}
; CHECK: define i32 (...)* @f2()
define i32 (...)* @f2() {
; CHECK-NEXT: load i32 (...)*, i32 (...)** bitcast (i8** getelementptr ([3 x i8*], [3 x i8*]* @vt, i64 1, i64 1) to i32 (...)**)
%load = load i32 (...)*, i32 (...)** getelementptr (i32 (...)*, i32 (...)** bitcast (i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @vt, i64 0, inrange i64 1) to i32 (...)**), i64 3)
ret i32 (...)* %load
}

View File

@ -0,0 +1,73 @@
; NOTE: This is a timeout test for some O(something silly) constant folding behaviour. It may not be the best test. Providing it finishes, it passes.
; RUN: opt < %s -O3 -S | FileCheck %s
target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
target triple = "armv8-none-eabi"
%struct.ST = type { %struct.ST* }
@global = internal global [121 x i8] zeroinitializer, align 1
define void @func() #0 {
;CHECK-LABEL: func
entry:
%s = alloca %struct.ST*, align 4
%j = alloca i32, align 4
store %struct.ST* bitcast ([121 x i8]* @global to %struct.ST*), %struct.ST** %s, align 4
store i32 0, i32* %j, align 4
br label %for.cond
for.cond: ; preds = %for.inc, %entry
%0 = load i32, i32* %j, align 4
%cmp = icmp slt i32 %0, 30
br i1 %cmp, label %for.body, label %for.end
for.body: ; preds = %for.cond
%1 = load %struct.ST*, %struct.ST** %s, align 4
%2 = bitcast %struct.ST* %1 to i8*
%add.ptr = getelementptr inbounds i8, i8* %2, i32 4
%3 = ptrtoint i8* %add.ptr to i32
%4 = load %struct.ST*, %struct.ST** %s, align 4
%5 = bitcast %struct.ST* %4 to i8*
%add.ptr1 = getelementptr inbounds i8, i8* %5, i32 4
%6 = ptrtoint i8* %add.ptr1 to i32
%rem = urem i32 %6, 2
%cmp2 = icmp eq i32 %rem, 0
br i1 %cmp2, label %cond.true, label %cond.false
cond.true: ; preds = %for.body
br label %cond.end
cond.false: ; preds = %for.body
%7 = load %struct.ST*, %struct.ST** %s, align 4
%8 = bitcast %struct.ST* %7 to i8*
%add.ptr3 = getelementptr inbounds i8, i8* %8, i32 4
%9 = ptrtoint i8* %add.ptr3 to i32
%rem4 = urem i32 %9, 2
br label %cond.end
cond.end: ; preds = %cond.false, %cond.true
%cond = phi i32 [ 0, %cond.true ], [ %rem4, %cond.false ]
%add = add i32 %3, %cond
%10 = inttoptr i32 %add to %struct.ST*
%11 = load %struct.ST*, %struct.ST** %s, align 4
%next = getelementptr inbounds %struct.ST, %struct.ST* %11, i32 0, i32 0
store %struct.ST* %10, %struct.ST** %next, align 4
%12 = load %struct.ST*, %struct.ST** %s, align 4
%next5 = getelementptr inbounds %struct.ST, %struct.ST* %12, i32 0, i32 0
%13 = load %struct.ST*, %struct.ST** %next5, align 4
store %struct.ST* %13, %struct.ST** %s, align 4
br label %for.inc
for.inc: ; preds = %cond.end
%14 = load i32, i32* %j, align 4
%inc = add nsw i32 %14, 1
store i32 %inc, i32* %j, align 4
br label %for.cond
for.end: ; preds = %for.cond
%15 = load %struct.ST*, %struct.ST** %s, align 4
%next6 = getelementptr inbounds %struct.ST, %struct.ST* %15, i32 0, i32 0
store %struct.ST* null, %struct.ST** %next6, align 4
ret void
}

View File

@ -0,0 +1,40 @@
; RUN: opt -instcombine -S -o - %s | FileCheck %s
; Tests that we don't crash upon encountering a vector GEP
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
%Dual = type { %Dual.72, %Partials.73 }
%Dual.72 = type { double, %Partials }
%Partials = type { [2 x double] }
%Partials.73 = type { [2 x %Dual.72] }
; Function Attrs: sspreq
define <8 x i64*> @"julia_axpy!_65480"(%Dual* %arg1, <8 x i64> %arg2) {
top:
; CHECK: %VectorGep14 = getelementptr inbounds %Dual, %Dual* %arg1, <8 x i64> %arg2, i32 1, i32 0, i64 0, i32 1, i32 0, i64 0
%VectorGep14 = getelementptr inbounds %Dual, %Dual* %arg1, <8 x i64> %arg2, i32 1, i32 0, i64 0, i32 1, i32 0, i64 0
%0 = bitcast <8 x double*> %VectorGep14 to <8 x i64*>
ret <8 x i64*> %0
}
%struct.A = type { i32, %struct.B* }
%struct.B = type { i64, %struct.C* }
%struct.C = type { i64 }
@G = internal global [65 x %struct.A] zeroinitializer, align 16
; CHECK-LABEL: @test
; CHECK: ret <16 x i32*> getelementptr ([65 x %struct.A], [65 x %struct.A]* @G, <16 x i64> zeroinitializer, <16 x i64> <i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7, i64 8, i64 9, i64 10, i64 11, i64 12, i64 13, i64 14, i64 15, i64 16>, <16 x i32> zeroinitializer)
define <16 x i32*> @test() {
vector.body:
%VectorGep = getelementptr [65 x %struct.A], [65 x %struct.A]* @G, <16 x i64> zeroinitializer, <16 x i64> <i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7, i64 8, i64 9, i64 10, i64 11, i64 12, i64 13, i64 14, i64 15, i64 16>, <16 x i32> zeroinitializer
ret <16 x i32*> %VectorGep
}
; CHECK-LABEL: @test2
; CHECK: ret <16 x i32*> getelementptr ([65 x %struct.A], [65 x %struct.A]* @G, <16 x i64> zeroinitializer, <16 x i64> <i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7, i64 8, i64 9,
define <16 x i32*> @test2() {
vector.body:
%VectorGep = getelementptr [65 x %struct.A], [65 x %struct.A]* @G, <16 x i32> zeroinitializer, <16 x i64> <i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7, i64 8, i64 9, i64 10, i64 11, i64 12, i64 13, i64 14, i64 15, i64 16>, <16 x i32> zeroinitializer
ret <16 x i32*> %VectorGep
}