1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -O2 -preserve-alignment-assumptions-during-inlining=0 < %s | FileCheck %s --check-prefixes=CHECK,ASSUMPTIONS-OFF
3 ; RUN: opt -S -O2 -preserve-alignment-assumptions-during-inlining=1 < %s | FileCheck %s --check-prefixes=CHECK,ASSUMPTIONS-ON
4 ; RUN: opt -S -O2 < %s | FileCheck %s --check-prefixes=CHECK,ASSUMPTIONS-OFF
6 target datalayout = "e-p:64:64-p5:32:32-A5"
8 ; This illustrates an optimization difference caused by instruction counting
9 ; heuristics, which are affected by the additional instructions of the
10 ; alignment assumption.
12 define internal i1 @callee1(i1 %c, i64* align 8 %ptr) {
13 store volatile i64 0, i64* %ptr
17 define void @caller1(i1 %c, i64* align 1 %ptr) {
18 ; ASSUMPTIONS-OFF-LABEL: @caller1(
19 ; ASSUMPTIONS-OFF-NEXT: br i1 [[C:%.*]], label [[COMMON_RET:%.*]], label [[FALSE2:%.*]]
20 ; ASSUMPTIONS-OFF: common.ret:
21 ; ASSUMPTIONS-OFF-NEXT: [[DOTSINK:%.*]] = phi i64 [ 3, [[FALSE2]] ], [ 2, [[TMP0:%.*]] ]
22 ; ASSUMPTIONS-OFF-NEXT: store volatile i64 0, i64* [[PTR:%.*]], align 8
23 ; ASSUMPTIONS-OFF-NEXT: store volatile i64 -1, i64* [[PTR]], align 4
24 ; ASSUMPTIONS-OFF-NEXT: store volatile i64 -1, i64* [[PTR]], align 4
25 ; ASSUMPTIONS-OFF-NEXT: store volatile i64 -1, i64* [[PTR]], align 4
26 ; ASSUMPTIONS-OFF-NEXT: store volatile i64 -1, i64* [[PTR]], align 4
27 ; ASSUMPTIONS-OFF-NEXT: store volatile i64 -1, i64* [[PTR]], align 4
28 ; ASSUMPTIONS-OFF-NEXT: store volatile i64 [[DOTSINK]], i64* [[PTR]], align 4
29 ; ASSUMPTIONS-OFF-NEXT: ret void
30 ; ASSUMPTIONS-OFF: false2:
31 ; ASSUMPTIONS-OFF-NEXT: store volatile i64 1, i64* [[PTR]], align 4
32 ; ASSUMPTIONS-OFF-NEXT: br label [[COMMON_RET]]
34 ; ASSUMPTIONS-ON-LABEL: @caller1(
35 ; ASSUMPTIONS-ON-NEXT: br i1 [[C:%.*]], label [[COMMON_RET:%.*]], label [[FALSE1:%.*]]
36 ; ASSUMPTIONS-ON: false1:
37 ; ASSUMPTIONS-ON-NEXT: store volatile i64 1, i64* [[PTR:%.*]], align 4
38 ; ASSUMPTIONS-ON-NEXT: br label [[COMMON_RET]]
39 ; ASSUMPTIONS-ON: common.ret:
40 ; ASSUMPTIONS-ON-NEXT: [[DOTSINK:%.*]] = phi i64 [ 3, [[FALSE1]] ], [ 2, [[TMP0:%.*]] ]
41 ; ASSUMPTIONS-ON-NEXT: call void @llvm.assume(i1 true) [ "align"(i64* [[PTR]], i64 8) ]
42 ; ASSUMPTIONS-ON-NEXT: store volatile i64 0, i64* [[PTR]], align 8
43 ; ASSUMPTIONS-ON-NEXT: store volatile i64 -1, i64* [[PTR]], align 8
44 ; ASSUMPTIONS-ON-NEXT: store volatile i64 -1, i64* [[PTR]], align 8
45 ; ASSUMPTIONS-ON-NEXT: store volatile i64 -1, i64* [[PTR]], align 8
46 ; ASSUMPTIONS-ON-NEXT: store volatile i64 -1, i64* [[PTR]], align 8
47 ; ASSUMPTIONS-ON-NEXT: store volatile i64 -1, i64* [[PTR]], align 8
48 ; ASSUMPTIONS-ON-NEXT: store volatile i64 [[DOTSINK]], i64* [[PTR]], align 8
49 ; ASSUMPTIONS-ON-NEXT: ret void
51 br i1 %c, label %true1, label %false1
54 %c2 = call i1 @callee1(i1 %c, i64* %ptr)
55 store volatile i64 -1, i64* %ptr
56 store volatile i64 -1, i64* %ptr
57 store volatile i64 -1, i64* %ptr
58 store volatile i64 -1, i64* %ptr
59 store volatile i64 -1, i64* %ptr
60 br i1 %c2, label %true2, label %false2
63 store volatile i64 1, i64* %ptr
67 store volatile i64 2, i64* %ptr
71 store volatile i64 3, i64* %ptr
75 ; This test checks that alignment assumptions do not prevent SROA.
78 define internal void @callee2(i64* noalias sret(i64) align 32 %arg) {
79 store i64 0, i64* %arg, align 8
83 define amdgpu_kernel void @caller2() {
84 ; CHECK-LABEL: @caller2(
85 ; CHECK-NEXT: ret void
87 %alloca = alloca i64, align 8, addrspace(5)
88 %cast = addrspacecast i64 addrspace(5)* %alloca to i64*
89 call void @callee2(i64* sret(i64) align 32 %cast)