1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
2*0a6a1f1dSLionel Sambuc
3*0a6a1f1dSLionel Sambuc typedef double * __attribute__((align_value(64))) aligned_double;
4*0a6a1f1dSLionel Sambuc
foo(aligned_double x,double * y,double & z)5*0a6a1f1dSLionel Sambuc void foo(aligned_double x, double * y __attribute__((align_value(32))),
6*0a6a1f1dSLionel Sambuc double & z __attribute__((align_value(128)))) { };
7*0a6a1f1dSLionel Sambuc // CHECK: define void @_Z3fooPdS_Rd(double* align 64 %x, double* align 32 %y, double* dereferenceable(8) align 128 %z)
8*0a6a1f1dSLionel Sambuc
9*0a6a1f1dSLionel Sambuc struct ad_struct {
10*0a6a1f1dSLionel Sambuc aligned_double a;
11*0a6a1f1dSLionel Sambuc };
12*0a6a1f1dSLionel Sambuc
foo(ad_struct & x)13*0a6a1f1dSLionel Sambuc double *foo(ad_struct& x) {
14*0a6a1f1dSLionel Sambuc // CHECK-LABEL: @_Z3fooR9ad_struct
15*0a6a1f1dSLionel Sambuc
16*0a6a1f1dSLionel Sambuc // CHECK: [[PTRINT1:%.+]] = ptrtoint
17*0a6a1f1dSLionel Sambuc // CHECK: [[MASKEDPTR1:%.+]] = and i64 [[PTRINT1]], 63
18*0a6a1f1dSLionel Sambuc // CHECK: [[MASKCOND1:%.+]] = icmp eq i64 [[MASKEDPTR1]], 0
19*0a6a1f1dSLionel Sambuc // CHECK: call void @llvm.assume(i1 [[MASKCOND1]])
20*0a6a1f1dSLionel Sambuc return x.a;
21*0a6a1f1dSLionel Sambuc }
22*0a6a1f1dSLionel Sambuc
goo(ad_struct * x)23*0a6a1f1dSLionel Sambuc double *goo(ad_struct *x) {
24*0a6a1f1dSLionel Sambuc // CHECK-LABEL: @_Z3gooP9ad_struct
25*0a6a1f1dSLionel Sambuc
26*0a6a1f1dSLionel Sambuc // CHECK: [[PTRINT2:%.+]] = ptrtoint
27*0a6a1f1dSLionel Sambuc // CHECK: [[MASKEDPTR2:%.+]] = and i64 [[PTRINT2]], 63
28*0a6a1f1dSLionel Sambuc // CHECK: [[MASKCOND2:%.+]] = icmp eq i64 [[MASKEDPTR2]], 0
29*0a6a1f1dSLionel Sambuc // CHECK: call void @llvm.assume(i1 [[MASKCOND2]])
30*0a6a1f1dSLionel Sambuc return x->a;
31*0a6a1f1dSLionel Sambuc }
32*0a6a1f1dSLionel Sambuc
bar(aligned_double * x)33*0a6a1f1dSLionel Sambuc double *bar(aligned_double *x) {
34*0a6a1f1dSLionel Sambuc // CHECK-LABEL: @_Z3barPPd
35*0a6a1f1dSLionel Sambuc
36*0a6a1f1dSLionel Sambuc // CHECK: [[PTRINT3:%.+]] = ptrtoint
37*0a6a1f1dSLionel Sambuc // CHECK: [[MASKEDPTR3:%.+]] = and i64 [[PTRINT3]], 63
38*0a6a1f1dSLionel Sambuc // CHECK: [[MASKCOND3:%.+]] = icmp eq i64 [[MASKEDPTR3]], 0
39*0a6a1f1dSLionel Sambuc // CHECK: call void @llvm.assume(i1 [[MASKCOND3]])
40*0a6a1f1dSLionel Sambuc return *x;
41*0a6a1f1dSLionel Sambuc }
42*0a6a1f1dSLionel Sambuc
car(aligned_double & x)43*0a6a1f1dSLionel Sambuc double *car(aligned_double &x) {
44*0a6a1f1dSLionel Sambuc // CHECK-LABEL: @_Z3carRPd
45*0a6a1f1dSLionel Sambuc
46*0a6a1f1dSLionel Sambuc // CHECK: [[PTRINT4:%.+]] = ptrtoint
47*0a6a1f1dSLionel Sambuc // CHECK: [[MASKEDPTR4:%.+]] = and i64 [[PTRINT4]], 63
48*0a6a1f1dSLionel Sambuc // CHECK: [[MASKCOND4:%.+]] = icmp eq i64 [[MASKEDPTR4]], 0
49*0a6a1f1dSLionel Sambuc // CHECK: call void @llvm.assume(i1 [[MASKCOND4]])
50*0a6a1f1dSLionel Sambuc return x;
51*0a6a1f1dSLionel Sambuc }
52*0a6a1f1dSLionel Sambuc
dar(aligned_double * x)53*0a6a1f1dSLionel Sambuc double *dar(aligned_double *x) {
54*0a6a1f1dSLionel Sambuc // CHECK-LABEL: @_Z3darPPd
55*0a6a1f1dSLionel Sambuc
56*0a6a1f1dSLionel Sambuc // CHECK: [[PTRINT5:%.+]] = ptrtoint
57*0a6a1f1dSLionel Sambuc // CHECK: [[MASKEDPTR5:%.+]] = and i64 [[PTRINT5]], 63
58*0a6a1f1dSLionel Sambuc // CHECK: [[MASKCOND5:%.+]] = icmp eq i64 [[MASKEDPTR5]], 0
59*0a6a1f1dSLionel Sambuc // CHECK: call void @llvm.assume(i1 [[MASKCOND5]])
60*0a6a1f1dSLionel Sambuc return x[5];
61*0a6a1f1dSLionel Sambuc }
62*0a6a1f1dSLionel Sambuc
63*0a6a1f1dSLionel Sambuc aligned_double eep();
ret()64*0a6a1f1dSLionel Sambuc double *ret() {
65*0a6a1f1dSLionel Sambuc // CHECK-LABEL: @_Z3retv
66*0a6a1f1dSLionel Sambuc
67*0a6a1f1dSLionel Sambuc // CHECK: [[PTRINT6:%.+]] = ptrtoint
68*0a6a1f1dSLionel Sambuc // CHECK: [[MASKEDPTR6:%.+]] = and i64 [[PTRINT6]], 63
69*0a6a1f1dSLionel Sambuc // CHECK: [[MASKCOND6:%.+]] = icmp eq i64 [[MASKEDPTR6]], 0
70*0a6a1f1dSLionel Sambuc // CHECK: call void @llvm.assume(i1 [[MASKCOND6]])
71*0a6a1f1dSLionel Sambuc return eep();
72*0a6a1f1dSLionel Sambuc }
73*0a6a1f1dSLionel Sambuc
no1(aligned_double * x)74*0a6a1f1dSLionel Sambuc double **no1(aligned_double *x) {
75*0a6a1f1dSLionel Sambuc // CHECK-LABEL: @_Z3no1PPd
76*0a6a1f1dSLionel Sambuc return x;
77*0a6a1f1dSLionel Sambuc // CHECK-NOT: call void @llvm.assume
78*0a6a1f1dSLionel Sambuc }
79*0a6a1f1dSLionel Sambuc
no2(aligned_double & x)80*0a6a1f1dSLionel Sambuc double *&no2(aligned_double &x) {
81*0a6a1f1dSLionel Sambuc // CHECK-LABEL: @_Z3no2RPd
82*0a6a1f1dSLionel Sambuc return x;
83*0a6a1f1dSLionel Sambuc // CHECK-NOT: call void @llvm.assume
84*0a6a1f1dSLionel Sambuc }
85*0a6a1f1dSLionel Sambuc
no3(aligned_double & x)86*0a6a1f1dSLionel Sambuc double **no3(aligned_double &x) {
87*0a6a1f1dSLionel Sambuc // CHECK-LABEL: @_Z3no3RPd
88*0a6a1f1dSLionel Sambuc return &x;
89*0a6a1f1dSLionel Sambuc // CHECK-NOT: call void @llvm.assume
90*0a6a1f1dSLionel Sambuc }
91*0a6a1f1dSLionel Sambuc
no3(aligned_double x)92*0a6a1f1dSLionel Sambuc double no3(aligned_double x) {
93*0a6a1f1dSLionel Sambuc // CHECK-LABEL: @_Z3no3Pd
94*0a6a1f1dSLionel Sambuc return *x;
95*0a6a1f1dSLionel Sambuc // CHECK-NOT: call void @llvm.assume
96*0a6a1f1dSLionel Sambuc }
97*0a6a1f1dSLionel Sambuc
no4(aligned_double x)98*0a6a1f1dSLionel Sambuc double *no4(aligned_double x) {
99*0a6a1f1dSLionel Sambuc // CHECK-LABEL: @_Z3no4Pd
100*0a6a1f1dSLionel Sambuc return x;
101*0a6a1f1dSLionel Sambuc // CHECK-NOT: call void @llvm.assume
102*0a6a1f1dSLionel Sambuc }
103*0a6a1f1dSLionel Sambuc
104