Imported Upstream version 6.0.0.172

Former-commit-id: f3cc9b82f3e5bd8f0fd3ebc098f789556b44e9cd
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2019-04-12 14:10:50 +00:00
parent 8016999e4d
commit 64ac736ec5
32155 changed files with 3981439 additions and 75368 deletions

View File

@@ -0,0 +1,140 @@
; RUN: opt -consthoist -S < %s | FileCheck %s
target triple = "thumbv6m-none-eabi"
; Allocas in the entry block get handled (for free) by
; prologue/epilogue. Elsewhere they're fair game though.
define void @avoid_allocas() {
; CHECK-LABEL: @avoid_allocas
; CHECK: %addr1 = alloca i8, i32 1000
; CHECK: %addr2 = alloca i8, i32 1020
%addr1 = alloca i8, i32 1000
%addr2 = alloca i8, i32 1020
br label %elsewhere
elsewhere:
; CHECK: [[BASE:%.*]] = bitcast i32 1000 to i32
; CHECK: alloca i8, i32 [[BASE]]
; CHECK: [[NEXT:%.*]] = add i32 [[BASE]], 20
; CHECK: alloca i8, i32 [[NEXT]]
%addr3 = alloca i8, i32 1000
%addr4 = alloca i8, i32 1020
ret void
}
; The case values of switch instructions are required to be constants.
define void @avoid_switch(i32 %in) {
; CHECK-LABEL: @avoid_switch
; CHECK: switch i32 %in, label %default [
; CHECK: i32 1000, label %bb1
; CHECK: i32 1020, label %bb2
; CHECK: ]
switch i32 %in, label %default
[ i32 1000, label %bb1
i32 1020, label %bb2 ]
bb1:
ret void
bb2:
ret void
default:
ret void
}
; We don't want to convert constant divides because the benefit from converting
; them to a mul in the backend is larget than constant materialization savings.
define void @signed_const_division(i32 %in1, i32 %in2, i32* %addr) {
; CHECK-LABEL: @signed_const_division
; CHECK: %res1 = sdiv i32 %l1, 1000000000
; CHECK: %res2 = srem i32 %l2, 1000000000
entry:
br label %loop
loop:
%l1 = phi i32 [%res1, %loop], [%in1, %entry]
%l2 = phi i32 [%res2, %loop], [%in2, %entry]
%res1 = sdiv i32 %l1, 1000000000
store volatile i32 %res1, i32* %addr
%res2 = srem i32 %l2, 1000000000
store volatile i32 %res2, i32* %addr
%again = icmp eq i32 %res1, %res2
br i1 %again, label %loop, label %end
end:
ret void
}
define void @unsigned_const_division(i32 %in1, i32 %in2, i32* %addr) {
; CHECK-LABEL: @unsigned_const_division
; CHECK: %res1 = udiv i32 %l1, 1000000000
; CHECK: %res2 = urem i32 %l2, 1000000000
entry:
br label %loop
loop:
%l1 = phi i32 [%res1, %loop], [%in1, %entry]
%l2 = phi i32 [%res2, %loop], [%in2, %entry]
%res1 = udiv i32 %l1, 1000000000
store volatile i32 %res1, i32* %addr
%res2 = urem i32 %l2, 1000000000
store volatile i32 %res2, i32* %addr
%again = icmp eq i32 %res1, %res2
br i1 %again, label %loop, label %end
end:
ret void
}
;PR 28282: even when data type is larger than 64-bit, the bit width of the
;constant operand could be smaller than 64-bit. In this case, there is no
;benefit to hoist the constant.
define i32 @struct_type_test(i96 %a0, i96 %a1) {
;CHECK-LABEL: @struct_type_test
entry:
;CHECK-NOT: %const = bitcast i96 32 to i96
;CHECK: lshr0 = lshr i96 %a0, 32
%lshr0 = lshr i96 %a0, 32
%cast0 = trunc i96 %lshr0 to i32
;CHECK: lshr1 = lshr i96 %a1, 32
%lshr1 = lshr i96 %a1, 32
%cast1 = trunc i96 %lshr1 to i32
%ret = add i32 %cast0, %cast1
ret i32 %ret
}
@exception_type = external global i8
; Constants in inline ASM should not be hoisted.
define i32 @inline_asm_invoke() personality i8* null {
;CHECK-LABEL: @inline_asm_invoke
;CHECK-NOT: %const = 214672
;CHECK: %X = invoke i32 asm "bswap $0", "=r,r"(i32 214672)
%X = invoke i32 asm "bswap $0", "=r,r"(i32 214672)
to label %L unwind label %lpad
;CHECK: %Y = invoke i32 asm "bswap $0", "=r,r"(i32 214672)
%Y = invoke i32 asm "bswap $0", "=r,r"(i32 214672)
to label %L unwind label %lpad
L:
ret i32 %X
lpad:
%lp = landingpad i32
cleanup
catch i8* @exception_type
ret i32 1
}
define i32 @inline_asm_call() {
;CHECK-LABEL: @inline_asm_call
;CHECK-NOT: %const = 214672
;CHECK: %X = call i32 asm "bswap $0", "=r,r"(i32 214672)
%X = call i32 asm "bswap $0", "=r,r"(i32 214672)
;CHECK: %Y = call i32 asm "bswap $0", "=r,r"(i32 214672)
%Y = call i32 asm "bswap $0", "=r,r"(i32 214672)
ret i32 %X
}

View File

@@ -0,0 +1,42 @@
; RUN: opt -mtriple=arm-arm-none-eabi -consthoist -S < %s | FileCheck %s
; There are different candidates here for the base constant: 1073876992 and
; 1073876996. But we don't want to see the latter because it results in
; negative offsets.
define void @foo() #0 {
entry:
; CHECK-LABEL: @foo
; CHECK-NOT: [[CONST1:%const_mat[0-9]*]] = add i32 %const, -4
%0 = load volatile i32, i32* inttoptr (i32 1073876992 to i32*), align 4096
%or = or i32 %0, 1
store volatile i32 %or, i32* inttoptr (i32 1073876992 to i32*), align 4096
%1 = load volatile i32, i32* inttoptr (i32 1073876996 to i32*), align 4
%and = and i32 %1, -117506048
store volatile i32 %and, i32* inttoptr (i32 1073876996 to i32*), align 4
%2 = load volatile i32, i32* inttoptr (i32 1073876992 to i32*), align 4096
%and1 = and i32 %2, -17367041
store volatile i32 %and1, i32* inttoptr (i32 1073876996 to i32*), align 4096
%3 = load volatile i32, i32* inttoptr (i32 1073876992 to i32*), align 4096
%and2 = and i32 %3, -262145
store volatile i32 %and2, i32* inttoptr (i32 1073876992 to i32*), align 4096
%4 = load volatile i32, i32* inttoptr (i32 1073876996 to i32*), align 4
%and3 = and i32 %4, -8323073
store volatile i32 %and3, i32* inttoptr (i32 1073876996 to i32*), align 4
store volatile i32 10420224, i32* inttoptr (i32 1073877000 to i32*), align 8
%5 = load volatile i32, i32* inttoptr (i32 1073876996 to i32*), align 4096
%or4 = or i32 %5, 65536
store volatile i32 %or4, i32* inttoptr (i32 1073876996 to i32*), align 4096
%6 = load volatile i32, i32* inttoptr (i32 1073881088 to i32*), align 8192
%or6.i.i = or i32 %6, 16
store volatile i32 %or6.i.i, i32* inttoptr (i32 1073881088 to i32*), align 8192
%7 = load volatile i32, i32* inttoptr (i32 1073881088 to i32*), align 8192
%and7.i.i = and i32 %7, -4
store volatile i32 %and7.i.i, i32* inttoptr (i32 1073881088 to i32*), align 8192
%8 = load volatile i32, i32* inttoptr (i32 1073881088 to i32*), align 8192
%or8.i.i = or i32 %8, 2
store volatile i32 %or8.i.i, i32* inttoptr (i32 1073881088 to i32*), align 8192
ret void
}
attributes #0 = { minsize norecurse nounwind optsize readnone uwtable }

View File

@@ -0,0 +1,37 @@
; RUN: opt -consthoist -S < %s | FileCheck %s
target triple = "thumbv6m-none-eabi"
%T = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32,
i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32,
i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32,
i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32,
i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32,
i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32,
i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32,
i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32,
i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32,
i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32,
i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32,
i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32,
i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32,
i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32,
i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32,
i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32,
i32, i32, i32, i32, i32, i32 }
; Indices for GEPs that index into a struct type should not be hoisted.
define i32 @test1(%T* %P) nounwind {
; CHECK-LABEL: @test1
; CHECK: %const = bitcast i32 256 to i32
; CHECK: %addr1 = getelementptr %T, %T* %P, i32 %const, i32 256
; CHECK: %addr2 = getelementptr %T, %T* %P, i32 %const, i32 256
; The first index into the pointer is hoisted, but the second one into the
; struct isn't.
%addr1 = getelementptr %T, %T* %P, i32 256, i32 256
%tmp1 = load i32, i32* %addr1
%addr2 = getelementptr %T, %T* %P, i32 256, i32 256
%tmp2 = load i32, i32* %addr2
%tmp4 = add i32 %tmp1, %tmp2
ret i32 %tmp4
}

View File

@@ -0,0 +1,31 @@
; RUN: opt -consthoist -S < %s | FileCheck %s
target triple = "thumbv6m-none-eabi"
%T = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32,
i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32,
i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32,
i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32,
i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32,
i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32,
i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32,
i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32,
i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32,
i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32,
i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32,
i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32,
i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32,
i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32,
i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32,
i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32,
i32, i32, i32, i32, i32, i32 }
; The second operand of insertvalue is able to be hoisted.
define void @test1(%T %P) {
; CHECK-LABEL: @test1
; CHECK: %const = bitcast i32 256 to i32
; CHECK: %1 = insertvalue %T %P, i32 %const, 256
; CHECK: %2 = insertvalue %T %P, i32 %const, 256
%1 = insertvalue %T %P, i32 256, 256
%2 = insertvalue %T %P, i32 256, 256
ret void
}

View File

@@ -0,0 +1,2 @@
if not 'ARM' in config.root.targets:
config.unsupported = True