You've already forked linux-packaging-mono
Imported Upstream version 5.18.0.167
Former-commit-id: 289509151e0fee68a1b591a20c9f109c3c789d3a
This commit is contained in:
parent
e19d552987
commit
b084638f15
@ -1,2 +0,0 @@
|
||||
if not 'NVPTX' in config.root.targets:
|
||||
config.unsupported = True
|
@ -1,144 +0,0 @@
|
||||
; RUN: opt < %s -nary-reassociate -early-cse -S | FileCheck %s
|
||||
; RUN: opt < %s -passes='nary-reassociate' -S | opt -early-cse -S | FileCheck %s
|
||||
|
||||
target datalayout = "e-i64:64-v16:16-v32:32-n16:32:64"
|
||||
target triple = "nvptx64-unknown-unknown"
|
||||
|
||||
declare void @foo(float*)
|
||||
|
||||
; foo(&a[i]);
|
||||
; foo(&a[i + j]);
|
||||
; =>
|
||||
; t = &a[i];
|
||||
; foo(t);
|
||||
; foo(t + j);
|
||||
define void @reassociate_gep(float* %a, i64 %i, i64 %j) {
|
||||
; CHECK-LABEL: @reassociate_gep(
|
||||
%1 = add i64 %i, %j
|
||||
%2 = getelementptr float, float* %a, i64 %i
|
||||
; CHECK: [[t1:[^ ]+]] = getelementptr float, float* %a, i64 %i
|
||||
call void @foo(float* %2)
|
||||
; CHECK: call void @foo(float* [[t1]])
|
||||
%3 = getelementptr float, float* %a, i64 %1
|
||||
; CHECK: [[t2:[^ ]+]] = getelementptr float, float* [[t1]], i64 %j
|
||||
call void @foo(float* %3)
|
||||
; CHECK: call void @foo(float* [[t2]])
|
||||
ret void
|
||||
}
|
||||
|
||||
; foo(&a[sext(j)]);
|
||||
; foo(&a[sext(i +nsw j)]);
|
||||
; foo(&a[sext((i +nsw j) +nsw i)]);
|
||||
; =>
|
||||
; t1 = &a[sext(j)];
|
||||
; foo(t1);
|
||||
; t2 = t1 + sext(i);
|
||||
; foo(t2);
|
||||
; t3 = t2 + sext(i); // sext(i) should be GVN'ed.
|
||||
; foo(t3);
|
||||
define void @reassociate_gep_nsw(float* %a, i32 %i, i32 %j) {
|
||||
; CHECK-LABEL: @reassociate_gep_nsw(
|
||||
%idxprom.j = sext i32 %j to i64
|
||||
%1 = getelementptr float, float* %a, i64 %idxprom.j
|
||||
; CHECK: [[t1:[^ ]+]] = getelementptr float, float* %a, i64 %idxprom.j
|
||||
call void @foo(float* %1)
|
||||
; CHECK: call void @foo(float* [[t1]])
|
||||
|
||||
%2 = add nsw i32 %i, %j
|
||||
%idxprom.2 = sext i32 %2 to i64
|
||||
%3 = getelementptr float, float* %a, i64 %idxprom.2
|
||||
; CHECK: [[sexti:[^ ]+]] = sext i32 %i to i64
|
||||
; CHECK: [[t2:[^ ]+]] = getelementptr float, float* [[t1]], i64 [[sexti]]
|
||||
call void @foo(float* %3)
|
||||
; CHECK: call void @foo(float* [[t2]])
|
||||
|
||||
%4 = add nsw i32 %2, %i
|
||||
%idxprom.4 = sext i32 %4 to i64
|
||||
%5 = getelementptr float, float* %a, i64 %idxprom.4
|
||||
; CHECK: [[t3:[^ ]+]] = getelementptr float, float* [[t2]], i64 [[sexti]]
|
||||
call void @foo(float* %5)
|
||||
; CHECK: call void @foo(float* [[t3]])
|
||||
|
||||
ret void
|
||||
}
|
||||
|
||||
; assume(j >= 0);
|
||||
; foo(&a[zext(j)]);
|
||||
; assume(i + j >= 0);
|
||||
; foo(&a[zext(i + j)]);
|
||||
; =>
|
||||
; t1 = &a[zext(j)];
|
||||
; foo(t1);
|
||||
; t2 = t1 + sext(i);
|
||||
; foo(t2);
|
||||
define void @reassociate_gep_assume(float* %a, i32 %i, i32 %j) {
|
||||
; CHECK-LABEL: @reassociate_gep_assume(
|
||||
; assume(j >= 0)
|
||||
%cmp = icmp sgt i32 %j, -1
|
||||
call void @llvm.assume(i1 %cmp)
|
||||
%1 = add i32 %i, %j
|
||||
%cmp2 = icmp sgt i32 %1, -1
|
||||
call void @llvm.assume(i1 %cmp2)
|
||||
|
||||
%idxprom.j = zext i32 %j to i64
|
||||
%2 = getelementptr float, float* %a, i64 %idxprom.j
|
||||
; CHECK: [[t1:[^ ]+]] = getelementptr float, float* %a, i64 %idxprom.j
|
||||
call void @foo(float* %2)
|
||||
; CHECK: call void @foo(float* [[t1]])
|
||||
|
||||
%idxprom.1 = zext i32 %1 to i64
|
||||
%3 = getelementptr float, float* %a, i64 %idxprom.1
|
||||
; CHECK: [[sexti:[^ ]+]] = sext i32 %i to i64
|
||||
; CHECK: [[t2:[^ ]+]] = getelementptr float, float* [[t1]], i64 [[sexti]]
|
||||
call void @foo(float* %3)
|
||||
; CHECK: call void @foo(float* [[t2]])
|
||||
|
||||
ret void
|
||||
}
|
||||
|
||||
; Do not split the second GEP because sext(i + j) != sext(i) + sext(j).
|
||||
define void @reassociate_gep_no_nsw(float* %a, i32 %i, i32 %j) {
|
||||
; CHECK-LABEL: @reassociate_gep_no_nsw(
|
||||
%1 = add i32 %i, %j
|
||||
%2 = getelementptr float, float* %a, i32 %j
|
||||
; CHECK: getelementptr float, float* %a, i32 %j
|
||||
call void @foo(float* %2)
|
||||
%3 = getelementptr float, float* %a, i32 %1
|
||||
; CHECK: getelementptr float, float* %a, i32 %1
|
||||
call void @foo(float* %3)
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @reassociate_gep_128(float* %a, i128 %i, i128 %j) {
|
||||
; CHECK-LABEL: @reassociate_gep_128(
|
||||
%1 = add i128 %i, %j
|
||||
%2 = getelementptr float, float* %a, i128 %i
|
||||
; CHECK: [[t1:[^ ]+]] = getelementptr float, float* %a, i128 %i
|
||||
call void @foo(float* %2)
|
||||
; CHECK: call void @foo(float* [[t1]])
|
||||
%3 = getelementptr float, float* %a, i128 %1
|
||||
; CHECK: [[truncj:[^ ]+]] = trunc i128 %j to i64
|
||||
; CHECK: [[t2:[^ ]+]] = getelementptr float, float* [[t1]], i64 [[truncj]]
|
||||
call void @foo(float* %3)
|
||||
; CHECK: call void @foo(float* [[t2]])
|
||||
ret void
|
||||
}
|
||||
|
||||
%struct.complex = type { float, float }
|
||||
|
||||
declare void @bar(%struct.complex*)
|
||||
|
||||
define void @different_types(%struct.complex* %input, i64 %i) {
|
||||
; CHECK-LABEL: @different_types(
|
||||
%t1 = getelementptr %struct.complex, %struct.complex* %input, i64 %i
|
||||
call void @bar(%struct.complex* %t1)
|
||||
%j = add i64 %i, 5
|
||||
%t2 = getelementptr %struct.complex, %struct.complex* %input, i64 %j, i32 0
|
||||
; CHECK: [[cast:[^ ]+]] = bitcast %struct.complex* %t1 to float*
|
||||
; CHECK-NEXT: %t2 = getelementptr float, float* [[cast]], i64 10
|
||||
; CHECK-NEXT: call void @foo(float* %t2)
|
||||
call void @foo(float* %t2)
|
||||
ret void
|
||||
}
|
||||
|
||||
declare void @llvm.assume(i1)
|
@ -1,48 +0,0 @@
|
||||
; RUN: opt < %s -slsr -nary-reassociate -S | FileCheck %s
|
||||
; RUN: opt < %s -slsr -S | opt -passes='nary-reassociate' -S | FileCheck %s
|
||||
; RUN: llc < %s -march=nvptx64 -mcpu=sm_20 | FileCheck %s --check-prefix=PTX
|
||||
|
||||
target datalayout = "e-i64:64-v16:16-v32:32-n16:32:64"
|
||||
|
||||
; foo((a + b) + c);
|
||||
; foo((a + b * 2) + c);
|
||||
; foo((a + b * 3) + c);
|
||||
; =>
|
||||
; abc = (a + b) + c;
|
||||
; foo(abc);
|
||||
; ab2c = abc + b;
|
||||
; foo(ab2c);
|
||||
; ab3c = ab2c + b;
|
||||
; foo(ab3c);
|
||||
define void @nary_reassociate_after_slsr(i32 %a, i32 %b, i32 %c) {
|
||||
; CHECK-LABEL: @nary_reassociate_after_slsr(
|
||||
; PTX-LABEL: .visible .func nary_reassociate_after_slsr(
|
||||
; PTX: ld.param.u32 [[b:%r[0-9]+]], [nary_reassociate_after_slsr_param_1];
|
||||
%ab = add i32 %a, %b
|
||||
%abc = add i32 %ab, %c
|
||||
call void @foo(i32 %abc)
|
||||
; CHECK: call void @foo(i32 %abc)
|
||||
; PTX: st.param.b32 [param0+0], [[abc:%r[0-9]+]];
|
||||
|
||||
%b2 = shl i32 %b, 1
|
||||
%ab2 = add i32 %a, %b2
|
||||
%ab2c = add i32 %ab2, %c
|
||||
; CHECK-NEXT: %ab2c = add i32 %abc, %b
|
||||
; PTX: add.s32 [[ab2c:%r[0-9]+]], [[abc]], [[b]]
|
||||
call void @foo(i32 %ab2c)
|
||||
; CHECK-NEXT: call void @foo(i32 %ab2c)
|
||||
; PTX: st.param.b32 [param0+0], [[ab2c]];
|
||||
|
||||
%b3 = mul i32 %b, 3
|
||||
%ab3 = add i32 %a, %b3
|
||||
%ab3c = add i32 %ab3, %c
|
||||
; CHECK-NEXT: %ab3c = add i32 %ab2c, %b
|
||||
; PTX: add.s32 [[ab3c:%r[0-9]+]], [[ab2c]], [[b]]
|
||||
call void @foo(i32 %ab3c)
|
||||
; CHECK-NEXT: call void @foo(i32 %ab3c)
|
||||
; PTX: st.param.b32 [param0+0], [[ab3c]];
|
||||
|
||||
ret void
|
||||
}
|
||||
|
||||
declare void @foo(i32)
|
@ -1,212 +0,0 @@
|
||||
; RUN: opt < %s -nary-reassociate -S | FileCheck %s
|
||||
; RUN: opt < %s -passes='nary-reassociate' -S | FileCheck %s
|
||||
|
||||
target datalayout = "e-i64:64-v16:16-v32:32-n16:32:64"
|
||||
|
||||
declare void @foo(i32)
|
||||
|
||||
; foo(a + c);
|
||||
; foo((a + (b + c));
|
||||
; =>
|
||||
; t = a + c;
|
||||
; foo(t);
|
||||
; foo(t + b);
|
||||
define void @left_reassociate(i32 %a, i32 %b, i32 %c) {
|
||||
; CHECK-LABEL: @left_reassociate(
|
||||
%1 = add i32 %a, %c
|
||||
; CHECK: [[BASE:%[a-zA-Z0-9]+]] = add i32 %a, %c
|
||||
call void @foo(i32 %1)
|
||||
%2 = add i32 %b, %c
|
||||
%3 = add i32 %a, %2
|
||||
; CHECK: [[RESULT:%[a-zA-Z0-9]+]] = add i32 [[BASE]], %b
|
||||
call void @foo(i32 %3)
|
||||
; CHECK-NEXT: call void @foo(i32 [[RESULT]])
|
||||
ret void
|
||||
}
|
||||
|
||||
; foo(a + c);
|
||||
; foo((a + b) + c);
|
||||
; =>
|
||||
; t = a + c;
|
||||
; foo(t);
|
||||
; foo(t + b);
|
||||
define void @right_reassociate(i32 %a, i32 %b, i32 %c) {
|
||||
; CHECK-LABEL: @right_reassociate(
|
||||
%1 = add i32 %a, %c
|
||||
; CHECK: [[BASE:%[a-zA-Z0-9]+]] = add i32 %a, %c
|
||||
call void @foo(i32 %1)
|
||||
%2 = add i32 %a, %b
|
||||
%3 = add i32 %2, %c
|
||||
; CHECK: [[RESULT:%[a-zA-Z0-9]+]] = add i32 [[BASE]], %b
|
||||
call void @foo(i32 %3)
|
||||
; CHECK-NEXT: call void @foo(i32 [[RESULT]])
|
||||
ret void
|
||||
}
|
||||
|
||||
; t1 = a + c;
|
||||
; foo(t1);
|
||||
; t2 = a + b;
|
||||
; foo(t2);
|
||||
; t3 = t2 + c;
|
||||
; foo(t3);
|
||||
;
|
||||
; Do not rewrite t3 into t1 + b because t2 is used elsewhere and is likely free.
|
||||
define void @no_reassociate(i32 %a, i32 %b, i32 %c) {
|
||||
; CHECK-LABEL: @no_reassociate(
|
||||
%1 = add i32 %a, %c
|
||||
; CHECK: add i32 %a, %c
|
||||
call void @foo(i32 %1)
|
||||
%2 = add i32 %a, %b
|
||||
; CHECK: add i32 %a, %b
|
||||
call void @foo(i32 %2)
|
||||
%3 = add i32 %2, %c
|
||||
; CHECK: add i32 %2, %c
|
||||
call void @foo(i32 %3)
|
||||
ret void
|
||||
}
|
||||
|
||||
; if (p1)
|
||||
; foo(a + c);
|
||||
; if (p2)
|
||||
; foo(a + c);
|
||||
; if (p3)
|
||||
; foo((a + b) + c);
|
||||
;
|
||||
; No action because (a + c) does not dominate ((a + b) + c).
|
||||
define void @conditional(i1 %p1, i1 %p2, i1 %p3, i32 %a, i32 %b, i32 %c) {
|
||||
; CHECK-LABEL: @conditional(
|
||||
entry:
|
||||
br i1 %p1, label %then1, label %branch1
|
||||
|
||||
then1:
|
||||
%0 = add i32 %a, %c
|
||||
; CHECK: add i32 %a, %c
|
||||
call void @foo(i32 %0)
|
||||
br label %branch1
|
||||
|
||||
branch1:
|
||||
br i1 %p2, label %then2, label %branch2
|
||||
|
||||
then2:
|
||||
%1 = add i32 %a, %c
|
||||
; CHECK: add i32 %a, %c
|
||||
call void @foo(i32 %1)
|
||||
br label %branch2
|
||||
|
||||
branch2:
|
||||
br i1 %p3, label %then3, label %return
|
||||
|
||||
then3:
|
||||
%2 = add i32 %a, %b
|
||||
; CHECK: %2 = add i32 %a, %b
|
||||
%3 = add i32 %2, %c
|
||||
; CHECK: add i32 %2, %c
|
||||
call void @foo(i32 %3)
|
||||
br label %return
|
||||
|
||||
return:
|
||||
ret void
|
||||
}
|
||||
|
||||
; This test involves more conditional reassociation candidates. It exercises
|
||||
; the stack optimization in tryReassociatedAdd that pops the candidates that
|
||||
; do not dominate the current instruction.
|
||||
;
|
||||
; def1
|
||||
; cond1
|
||||
; / \
|
||||
; / \
|
||||
; cond2 use2
|
||||
; / \
|
||||
; / \
|
||||
; def2 def3
|
||||
; cond3
|
||||
; / \
|
||||
; / \
|
||||
; def4 use1
|
||||
;
|
||||
; NaryReassociate should match use1 with def3, and use2 with def1.
|
||||
define void @conditional2(i32 %a, i32 %b, i32 %c, i1 %cond1, i1 %cond2, i1 %cond3) {
|
||||
entry:
|
||||
%def1 = add i32 %a, %b
|
||||
br i1 %cond1, label %bb1, label %bb6
|
||||
bb1:
|
||||
br i1 %cond2, label %bb2, label %bb3
|
||||
bb2:
|
||||
%def2 = add i32 %a, %b
|
||||
call void @foo(i32 %def2)
|
||||
ret void
|
||||
bb3:
|
||||
%def3 = add i32 %a, %b
|
||||
br i1 %cond3, label %bb4, label %bb5
|
||||
bb4:
|
||||
%def4 = add i32 %a, %b
|
||||
call void @foo(i32 %def4)
|
||||
ret void
|
||||
bb5:
|
||||
%0 = add i32 %a, %c
|
||||
%1 = add i32 %0, %b
|
||||
; CHECK: [[t1:%[0-9]+]] = add i32 %def3, %c
|
||||
call void @foo(i32 %1) ; foo((a + c) + b);
|
||||
; CHECK-NEXT: call void @foo(i32 [[t1]])
|
||||
ret void
|
||||
bb6:
|
||||
%2 = add i32 %a, %c
|
||||
%3 = add i32 %2, %b
|
||||
; CHECK: [[t2:%[0-9]+]] = add i32 %def1, %c
|
||||
call void @foo(i32 %3) ; foo((a + c) + b);
|
||||
; CHECK-NEXT: call void @foo(i32 [[t2]])
|
||||
ret void
|
||||
}
|
||||
|
||||
; foo((a + b) + c)
|
||||
; foo(((a + d) + b) + c)
|
||||
; =>
|
||||
; t = (a + b) + c;
|
||||
; foo(t);
|
||||
; foo(t + d);
|
||||
define void @quaternary(i32 %a, i32 %b, i32 %c, i32 %d) {
|
||||
; CHECK-LABEL: @quaternary(
|
||||
%1 = add i32 %a, %b
|
||||
%2 = add i32 %1, %c
|
||||
call void @foo(i32 %2)
|
||||
; CHECK: call void @foo(i32 [[TMP1:%[a-zA-Z0-9]]])
|
||||
%3 = add i32 %a, %d
|
||||
%4 = add i32 %3, %b
|
||||
%5 = add i32 %4, %c
|
||||
; CHECK: [[TMP2:%[a-zA-Z0-9]]] = add i32 [[TMP1]], %d
|
||||
call void @foo(i32 %5)
|
||||
; CHECK: call void @foo(i32 [[TMP2]]
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @iterative(i32 %a, i32 %b, i32 %c) {
|
||||
%ab = add i32 %a, %b
|
||||
%abc = add i32 %ab, %c
|
||||
call void @foo(i32 %abc)
|
||||
|
||||
%ab2 = add i32 %ab, %b
|
||||
%ab2c = add i32 %ab2, %c
|
||||
; CHECK: %ab2c = add i32 %abc, %b
|
||||
call void @foo(i32 %ab2c)
|
||||
; CHECK-NEXT: call void @foo(i32 %ab2c)
|
||||
|
||||
%ab3 = add i32 %ab2, %b
|
||||
%ab3c = add i32 %ab3, %c
|
||||
; CHECK-NEXT: %ab3c = add i32 %ab2c, %b
|
||||
call void @foo(i32 %ab3c)
|
||||
; CHECK-NEXT: call void @foo(i32 %ab3c)
|
||||
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @avoid_infinite_loop(i32 %a, i32 %b) {
|
||||
; CHECK-LABEL: @avoid_infinite_loop
|
||||
%ab = add i32 %a, %b
|
||||
; CHECK-NEXT: %ab
|
||||
%ab2 = add i32 %ab, %b
|
||||
; CHECK-NEXT: %ab2
|
||||
call void @foo(i32 %ab2)
|
||||
; CHECK-NEXT: @foo(i32 %ab2)
|
||||
ret void
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
; RUN: opt < %s -nary-reassociate -S | FileCheck %s
|
||||
; RUN: opt < %s -passes='nary-reassociate' -S | FileCheck %s
|
||||
|
||||
target datalayout = "e-i64:64-v16:16-v32:32-n16:32:64"
|
||||
|
||||
declare void @foo(i32)
|
||||
|
||||
; CHECK-LABEL: @bar(
|
||||
define void @bar(i32 %a, i32 %b, i32 %c) {
|
||||
%1 = mul i32 %a, %c
|
||||
; CHECK: [[BASE:%[a-zA-Z0-9]+]] = mul i32 %a, %c
|
||||
call void @foo(i32 %1)
|
||||
%2 = mul i32 %a, %b
|
||||
%3 = mul i32 %2, %c
|
||||
; CHECK: [[RESULT:%[a-zA-Z0-9]+]] = mul i32 [[BASE]], %b
|
||||
call void @foo(i32 %3)
|
||||
; CHECK-NEXT: call void @foo(i32 [[RESULT]])
|
||||
ret void
|
||||
}
|
||||
|
@ -1,15 +0,0 @@
|
||||
; RUN: opt < %s -nary-reassociate -S | FileCheck %s
|
||||
; RUN: opt < %s -passes='nary-reassociate' -S | FileCheck %s
|
||||
|
||||
define i32 @foo(i32 %tmp4) {
|
||||
; CHECK-LABEL: @foo(
|
||||
entry:
|
||||
%tmp5 = add i32 %tmp4, 8
|
||||
%tmp13 = add i32 %tmp4, -128 ; deleted
|
||||
%tmp14 = add i32 %tmp13, 8 ; => %tmp5 + -128
|
||||
%tmp21 = add i32 119, %tmp4
|
||||
; do not rewrite %tmp23 against %tmp13 because %tmp13 is already deleted
|
||||
%tmp23 = add i32 %tmp21, -128
|
||||
; CHECK: %tmp23 = add i32 %tmp21, -128
|
||||
ret i32 %tmp23
|
||||
}
|
Reference in New Issue
Block a user