2020-03-26 06:35:19 +08:00
|
|
|
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
|
|
|
; RUN: opt -S -O2 -preserve-alignment-assumptions-during-inlining=0 < %s | FileCheck %s --check-prefixes=CHECK,ASSUMPTIONS-OFF,FALLBACK-0
|
|
|
|
; RUN: opt -S -O2 -preserve-alignment-assumptions-during-inlining=1 < %s | FileCheck %s --check-prefixes=CHECK,ASSUMPTIONS-ON,FALLBACK-1
|
|
|
|
; RUN: opt -S -O2 < %s | FileCheck %s --check-prefixes=CHECK,ASSUMPTIONS-OFF,FALLBACK-DEFAULT
|
|
|
|
|
|
|
|
target datalayout = "e-p:64:64-p5:32:32-A5"
|
|
|
|
|
|
|
|
; This illustrates an optimization difference caused by instruction counting
|
|
|
|
; heuristics, which are affected by the additional instructions of the
|
|
|
|
; alignment assumption.
|
|
|
|
|
|
|
|
define internal i1 @callee1(i1 %c, i64* align 8 %ptr) {
|
|
|
|
store volatile i64 0, i64* %ptr
|
|
|
|
ret i1 %c
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @caller1(i1 %c, i64* align 1 %ptr) {
|
|
|
|
; ASSUMPTIONS-OFF-LABEL: @caller1(
|
|
|
|
; ASSUMPTIONS-OFF-NEXT: br i1 [[C:%.*]], label [[TRUE2:%.*]], label [[FALSE2:%.*]]
|
|
|
|
; ASSUMPTIONS-OFF: true2:
|
|
|
|
; ASSUMPTIONS-OFF-NEXT: store volatile i64 0, i64* [[PTR:%.*]], align 8
|
|
|
|
; ASSUMPTIONS-OFF-NEXT: store volatile i64 -1, i64* [[PTR]], align 4
|
|
|
|
; ASSUMPTIONS-OFF-NEXT: store volatile i64 -1, i64* [[PTR]], align 4
|
|
|
|
; ASSUMPTIONS-OFF-NEXT: store volatile i64 -1, i64* [[PTR]], align 4
|
|
|
|
; ASSUMPTIONS-OFF-NEXT: store volatile i64 -1, i64* [[PTR]], align 4
|
|
|
|
; ASSUMPTIONS-OFF-NEXT: store volatile i64 -1, i64* [[PTR]], align 4
|
|
|
|
; ASSUMPTIONS-OFF-NEXT: store volatile i64 2, i64* [[PTR]], align 4
|
|
|
|
; ASSUMPTIONS-OFF-NEXT: ret void
|
|
|
|
; ASSUMPTIONS-OFF: false2:
|
|
|
|
; ASSUMPTIONS-OFF-NEXT: store volatile i64 1, i64* [[PTR]], align 4
|
|
|
|
; ASSUMPTIONS-OFF-NEXT: store volatile i64 0, i64* [[PTR]], align 8
|
|
|
|
; ASSUMPTIONS-OFF-NEXT: store volatile i64 -1, i64* [[PTR]], align 4
|
|
|
|
; ASSUMPTIONS-OFF-NEXT: store volatile i64 -1, i64* [[PTR]], align 4
|
|
|
|
; ASSUMPTIONS-OFF-NEXT: store volatile i64 -1, i64* [[PTR]], align 4
|
|
|
|
; ASSUMPTIONS-OFF-NEXT: store volatile i64 -1, i64* [[PTR]], align 4
|
|
|
|
; ASSUMPTIONS-OFF-NEXT: store volatile i64 -1, i64* [[PTR]], align 4
|
|
|
|
; ASSUMPTIONS-OFF-NEXT: store volatile i64 3, i64* [[PTR]], align 4
|
|
|
|
; ASSUMPTIONS-OFF-NEXT: ret void
|
|
|
|
;
|
|
|
|
; ASSUMPTIONS-ON-LABEL: @caller1(
|
[AssumeBundles] Use operand bundles to encode alignment assumptions
Summary:
NOTE: There is a mailing list discussion on this: http://lists.llvm.org/pipermail/llvm-dev/2019-December/137632.html
Complemantary to the assumption outliner prototype in D71692, this patch
shows how we could simplify the code emitted for an alignemnt
assumption. The generated code is smaller, less fragile, and it makes it
easier to recognize the additional use as a "assumption use".
As mentioned in D71692 and on the mailing list, we could adopt this
scheme, and similar schemes for other patterns, without adopting the
assumption outlining.
Reviewers: hfinkel, xbolva00, lebedev.ri, nikic, rjmccall, spatel, jdoerfert, sstefan1
Reviewed By: jdoerfert
Subscribers: yamauchi, kuter, fhahn, merge_guards_bot, hiraditya, bollu, rkruppe, cfe-commits, llvm-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D71739
2020-06-24 19:18:21 +08:00
|
|
|
; ASSUMPTIONS-ON-NEXT: br i1 [[C:%.*]], label [[TRUE2_CRITEDGE:%.*]], label [[FALSE1:%.*]]
|
|
|
|
; ASSUMPTIONS-ON: false1:
|
|
|
|
; ASSUMPTIONS-ON-NEXT: store volatile i64 1, i64* [[PTR:%.*]], align 8
|
2020-07-17 02:40:43 +08:00
|
|
|
; ASSUMPTIONS-ON-NEXT: [[PTRINT:%.*]] = ptrtoint i64* [[PTR]] to i64
|
|
|
|
; ASSUMPTIONS-ON-NEXT: [[MASKEDPTR:%.*]] = and i64 [[PTRINT]], 7
|
|
|
|
; ASSUMPTIONS-ON-NEXT: [[MASKCOND:%.*]] = icmp eq i64 [[MASKEDPTR]], 0
|
|
|
|
; ASSUMPTIONS-ON-NEXT: tail call void @llvm.assume(i1 [[MASKCOND]])
|
2020-03-26 06:35:19 +08:00
|
|
|
; ASSUMPTIONS-ON-NEXT: store volatile i64 0, i64* [[PTR]], align 8
|
|
|
|
; ASSUMPTIONS-ON-NEXT: store volatile i64 -1, i64* [[PTR]], align 8
|
|
|
|
; ASSUMPTIONS-ON-NEXT: store volatile i64 -1, i64* [[PTR]], align 8
|
|
|
|
; ASSUMPTIONS-ON-NEXT: store volatile i64 -1, i64* [[PTR]], align 8
|
|
|
|
; ASSUMPTIONS-ON-NEXT: store volatile i64 -1, i64* [[PTR]], align 8
|
|
|
|
; ASSUMPTIONS-ON-NEXT: store volatile i64 -1, i64* [[PTR]], align 8
|
|
|
|
; ASSUMPTIONS-ON-NEXT: store volatile i64 3, i64* [[PTR]], align 8
|
|
|
|
; ASSUMPTIONS-ON-NEXT: ret void
|
[AssumeBundles] Use operand bundles to encode alignment assumptions
Summary:
NOTE: There is a mailing list discussion on this: http://lists.llvm.org/pipermail/llvm-dev/2019-December/137632.html
Complemantary to the assumption outliner prototype in D71692, this patch
shows how we could simplify the code emitted for an alignemnt
assumption. The generated code is smaller, less fragile, and it makes it
easier to recognize the additional use as a "assumption use".
As mentioned in D71692 and on the mailing list, we could adopt this
scheme, and similar schemes for other patterns, without adopting the
assumption outlining.
Reviewers: hfinkel, xbolva00, lebedev.ri, nikic, rjmccall, spatel, jdoerfert, sstefan1
Reviewed By: jdoerfert
Subscribers: yamauchi, kuter, fhahn, merge_guards_bot, hiraditya, bollu, rkruppe, cfe-commits, llvm-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D71739
2020-06-24 19:18:21 +08:00
|
|
|
; ASSUMPTIONS-ON: true2.critedge:
|
2020-07-17 02:40:43 +08:00
|
|
|
; ASSUMPTIONS-ON-NEXT: [[PTRINT_C:%.*]] = ptrtoint i64* [[PTR]] to i64
|
|
|
|
; ASSUMPTIONS-ON-NEXT: [[MASKEDPTR_C:%.*]] = and i64 [[PTRINT_C]], 7
|
|
|
|
; ASSUMPTIONS-ON-NEXT: [[MASKCOND_C:%.*]] = icmp eq i64 [[MASKEDPTR_C]], 0
|
|
|
|
; ASSUMPTIONS-ON-NEXT: tail call void @llvm.assume(i1 [[MASKCOND_C]])
|
[AssumeBundles] Use operand bundles to encode alignment assumptions
Summary:
NOTE: There is a mailing list discussion on this: http://lists.llvm.org/pipermail/llvm-dev/2019-December/137632.html
Complemantary to the assumption outliner prototype in D71692, this patch
shows how we could simplify the code emitted for an alignemnt
assumption. The generated code is smaller, less fragile, and it makes it
easier to recognize the additional use as a "assumption use".
As mentioned in D71692 and on the mailing list, we could adopt this
scheme, and similar schemes for other patterns, without adopting the
assumption outlining.
Reviewers: hfinkel, xbolva00, lebedev.ri, nikic, rjmccall, spatel, jdoerfert, sstefan1
Reviewed By: jdoerfert
Subscribers: yamauchi, kuter, fhahn, merge_guards_bot, hiraditya, bollu, rkruppe, cfe-commits, llvm-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D71739
2020-06-24 19:18:21 +08:00
|
|
|
; ASSUMPTIONS-ON-NEXT: store volatile i64 0, i64* [[PTR]], align 8
|
|
|
|
; ASSUMPTIONS-ON-NEXT: store volatile i64 -1, i64* [[PTR]], align 8
|
|
|
|
; ASSUMPTIONS-ON-NEXT: store volatile i64 -1, i64* [[PTR]], align 8
|
|
|
|
; ASSUMPTIONS-ON-NEXT: store volatile i64 -1, i64* [[PTR]], align 8
|
|
|
|
; ASSUMPTIONS-ON-NEXT: store volatile i64 -1, i64* [[PTR]], align 8
|
|
|
|
; ASSUMPTIONS-ON-NEXT: store volatile i64 -1, i64* [[PTR]], align 8
|
|
|
|
; ASSUMPTIONS-ON-NEXT: store volatile i64 2, i64* [[PTR]], align 8
|
|
|
|
; ASSUMPTIONS-ON-NEXT: ret void
|
2020-03-26 06:35:19 +08:00
|
|
|
;
|
|
|
|
br i1 %c, label %true1, label %false1
|
|
|
|
|
|
|
|
true1:
|
|
|
|
%c2 = call i1 @callee1(i1 %c, i64* %ptr)
|
|
|
|
store volatile i64 -1, i64* %ptr
|
|
|
|
store volatile i64 -1, i64* %ptr
|
|
|
|
store volatile i64 -1, i64* %ptr
|
|
|
|
store volatile i64 -1, i64* %ptr
|
|
|
|
store volatile i64 -1, i64* %ptr
|
|
|
|
br i1 %c2, label %true2, label %false2
|
|
|
|
|
|
|
|
false1:
|
|
|
|
store volatile i64 1, i64* %ptr
|
|
|
|
br label %true1
|
|
|
|
|
|
|
|
true2:
|
|
|
|
store volatile i64 2, i64* %ptr
|
|
|
|
ret void
|
|
|
|
|
|
|
|
false2:
|
|
|
|
store volatile i64 3, i64* %ptr
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2020-06-16 00:37:07 +08:00
|
|
|
; This test checks that alignment assumptions do not prevent SROA.
|
2020-03-26 06:35:19 +08:00
|
|
|
; See PR45763.
|
|
|
|
|
2020-07-17 02:40:43 +08:00
|
|
|
define internal void @callee2(i64* noalias sret align 8 %arg) {
|
2020-03-26 06:35:19 +08:00
|
|
|
store i64 0, i64* %arg, align 8
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
define amdgpu_kernel void @caller2() {
|
2020-07-17 02:40:43 +08:00
|
|
|
; ASSUMPTIONS-OFF-LABEL: @caller2(
|
|
|
|
; ASSUMPTIONS-OFF-NEXT: ret void
|
|
|
|
;
|
|
|
|
; ASSUMPTIONS-ON-LABEL: @caller2(
|
|
|
|
; ASSUMPTIONS-ON-NEXT: [[ALLOCA:%.*]] = alloca i64, align 8, addrspace(5)
|
|
|
|
; ASSUMPTIONS-ON-NEXT: [[CAST:%.*]] = addrspacecast i64 addrspace(5)* [[ALLOCA]] to i64*
|
|
|
|
; ASSUMPTIONS-ON-NEXT: [[PTRINT:%.*]] = ptrtoint i64* [[CAST]] to i64
|
|
|
|
; ASSUMPTIONS-ON-NEXT: [[MASKEDPTR:%.*]] = and i64 [[PTRINT]], 7
|
|
|
|
; ASSUMPTIONS-ON-NEXT: [[MASKCOND:%.*]] = icmp eq i64 [[MASKEDPTR]], 0
|
|
|
|
; ASSUMPTIONS-ON-NEXT: call void @llvm.assume(i1 [[MASKCOND]])
|
|
|
|
; ASSUMPTIONS-ON-NEXT: ret void
|
2020-03-26 06:35:19 +08:00
|
|
|
;
|
|
|
|
%alloca = alloca i64, align 8, addrspace(5)
|
|
|
|
%cast = addrspacecast i64 addrspace(5)* %alloca to i64*
|
2020-07-17 02:40:43 +08:00
|
|
|
call void @callee2(i64* sret align 8 %cast)
|
2020-03-26 06:35:19 +08:00
|
|
|
ret void
|
|
|
|
}
|