blob: 0ddb2378ef2f2fe8b016237a31c28b5916804f5a [file] [log] [blame]
Charles Davis5dfa2672010-02-19 18:17:13 +00001; RUN: llc < %s -relocation-model=static -realign-stack=1 -mcpu=yonah | FileCheck %s
Chris Lattner1329cb82008-01-26 19:45:50 +00002
3; The double argument is at 4(esp) which is 16-byte aligned, allowing us to
4; fold the load into the andpd.
5
6target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
7target triple = "i686-apple-darwin8"
8@G = external global double
9
Chris Lattner0a9481f2011-02-13 22:25:43 +000010define void @test({ double, double }* byval %z, double* %P) nounwind {
Chris Lattner1329cb82008-01-26 19:45:50 +000011entry:
Chris Lattner1329cb82008-01-26 19:45:50 +000012 %tmp3 = load double* @G, align 16 ; <double> [#uses=1]
Bob Wilson53624a22012-08-03 23:29:17 +000013 %tmp4 = tail call double @fabs( double %tmp3 ) readnone ; <double> [#uses=1]
Chris Lattnerd2bf4322011-11-27 06:54:59 +000014 store volatile double %tmp4, double* %P
Dan Gohman584fedf2010-06-21 22:17:20 +000015 %tmp = getelementptr { double, double }* %z, i32 0, i32 0 ; <double*> [#uses=1]
Chris Lattnerd2bf4322011-11-27 06:54:59 +000016 %tmp1 = load volatile double* %tmp, align 8 ; <double> [#uses=1]
Bob Wilson53624a22012-08-03 23:29:17 +000017 %tmp2 = tail call double @fabs( double %tmp1 ) readnone ; <double> [#uses=1]
Dan Gohman584fedf2010-06-21 22:17:20 +000018 ; CHECK: andpd{{.*}}4(%esp), %xmm
Dan Gohmanae3a0be2009-06-04 22:49:04 +000019 %tmp6 = fadd double %tmp4, %tmp2 ; <double> [#uses=1]
Chris Lattnerd2bf4322011-11-27 06:54:59 +000020 store volatile double %tmp6, double* %P, align 8
Chris Lattner1329cb82008-01-26 19:45:50 +000021 ret void
22}
23
Chris Lattner0a9481f2011-02-13 22:25:43 +000024define void @test2() alignstack(16) nounwind {
Charles Davis5dfa2672010-02-19 18:17:13 +000025entry:
26 ; CHECK: andl{{.*}}$-16, %esp
27 ret void
28}
29
30; Use a call to force a spill.
Chris Lattner0a9481f2011-02-13 22:25:43 +000031define <2 x double> @test3(<2 x double> %x, <2 x double> %y) alignstack(32) nounwind {
Charles Davis5dfa2672010-02-19 18:17:13 +000032entry:
33 ; CHECK: andl{{.*}}$-32, %esp
34 call void @test2()
Dan Gohmand4d01152010-05-03 22:36:46 +000035 %A = fmul <2 x double> %x, %y
Charles Davis5dfa2672010-02-19 18:17:13 +000036 ret <2 x double> %A
37}
38
Chris Lattner1329cb82008-01-26 19:45:50 +000039declare double @fabs(double)
Charles Davis5dfa2672010-02-19 18:17:13 +000040
Chris Lattner0a9481f2011-02-13 22:25:43 +000041; The pointer is already known aligned, so and x,-16 is eliminable.
42define i32 @test4() nounwind {
43entry:
44 %buffer = alloca [2048 x i8], align 16
45 %0 = ptrtoint [2048 x i8]* %buffer to i32
46 %and = and i32 %0, -16
47 ret i32 %and
48; CHECK: test4:
49; CHECK-NOT: and
50; CHECK: ret
51}