blob: b199d699811402da006364df62a9950c864105d3 [file] [log] [blame]
Evan Cheng9085f982010-05-19 07:28:01 +00001; RUN: llc < %s -mtriple=thumbv7-apple-darwin -mcpu=cortex-a8 -disable-fp-elim | FileCheck %s
2; RUN: llc < %s -mtriple=thumbv7-apple-darwin -mcpu=cortex-a8 -relocation-model=pic -disable-fp-elim | FileCheck %s --check-prefix=PIC
Evan Cheng9eda6892009-10-31 03:39:36 +00003; rdar://7353541
Evan Chengd457e6e2009-11-07 04:04:34 +00004; rdar://7354376
Evan Cheng9eda6892009-10-31 03:39:36 +00005
Evan Cheng9eda6892009-10-31 03:39:36 +00006@GV = external global i32 ; <i32*> [#uses=2]
7
Rafael Espindola1e819662010-06-17 15:18:27 +00008define void @t1(i32* nocapture %vals, i32 %c) nounwind {
Evan Cheng9eda6892009-10-31 03:39:36 +00009entry:
Evan Cheng9085f982010-05-19 07:28:01 +000010; CHECK: t1:
Jim Grosbach25e6d482011-07-08 21:50:04 +000011; CHECK: bxeq lr
12
Evan Cheng9eda6892009-10-31 03:39:36 +000013 %0 = icmp eq i32 %c, 0 ; <i1> [#uses=1]
14 br i1 %0, label %return, label %bb.nph
15
16bb.nph: ; preds = %entry
Jakob Stoklund Olesend5b679c2011-04-30 01:37:52 +000017; CHECK: movw r[[R2:[0-9]+]], :lower16:L_GV$non_lazy_ptr
18; CHECK: movt r[[R2]], :upper16:L_GV$non_lazy_ptr
19; CHECK: ldr{{(.w)?}} r[[R2b:[0-9]+]], [r[[R2]]
20; CHECK: ldr{{.*}}, [r[[R2b]]
Jim Grosbach25e6d482011-07-08 21:50:04 +000021; CHECK: LBB0_
Evan Cheng53519f02011-01-21 18:55:51 +000022; CHECK-NOT: LCPI0_0:
Evan Cheng9b824252009-11-20 02:10:27 +000023
Jakob Stoklund Olesend5b679c2011-04-30 01:37:52 +000024; PIC: movw r[[R2:[0-9]+]], :lower16:(L_GV$non_lazy_ptr-(LPC0_0+4))
25; PIC: movt r[[R2]], :upper16:(L_GV$non_lazy_ptr-(LPC0_0+4))
26; PIC: add r[[R2]], pc
27; PIC: ldr{{(.w)?}} r[[R2b:[0-9]+]], [r[[R2]]
28; PIC: ldr{{.*}}, [r[[R2b]]
Jim Grosbach25e6d482011-07-08 21:50:04 +000029; PIC: LBB0_
Evan Cheng53519f02011-01-21 18:55:51 +000030; PIC-NOT: LCPI0_0:
Evan Cheng9b824252009-11-20 02:10:27 +000031; PIC: .section
Evan Cheng9eda6892009-10-31 03:39:36 +000032 %.pre = load i32* @GV, align 4 ; <i32> [#uses=1]
33 br label %bb
34
35bb: ; preds = %bb, %bb.nph
36 %1 = phi i32 [ %.pre, %bb.nph ], [ %3, %bb ] ; <i32> [#uses=1]
37 %i.03 = phi i32 [ 0, %bb.nph ], [ %4, %bb ] ; <i32> [#uses=2]
38 %scevgep = getelementptr i32* %vals, i32 %i.03 ; <i32*> [#uses=1]
39 %2 = load i32* %scevgep, align 4 ; <i32> [#uses=1]
40 %3 = add nsw i32 %1, %2 ; <i32> [#uses=2]
41 store i32 %3, i32* @GV, align 4
42 %4 = add i32 %i.03, 1 ; <i32> [#uses=2]
43 %exitcond = icmp eq i32 %4, %c ; <i1> [#uses=1]
44 br i1 %exitcond, label %return, label %bb
45
46return: ; preds = %bb, %entry
47 ret void
48}
Evan Cheng9085f982010-05-19 07:28:01 +000049
50; rdar://8001136
Rafael Espindola1e819662010-06-17 15:18:27 +000051define void @t2(i8* %ptr1, i8* %ptr2) nounwind {
Evan Cheng9085f982010-05-19 07:28:01 +000052entry:
53; CHECK: t2:
Jakob Stoklund Olesen2aa6b4c2011-07-08 00:24:06 +000054; CHECK: mov.w [[R3:r[0-9]+]], #1065353216
55; CHECK: vdup.32 q{{.*}}, [[R3]]
Evan Cheng9085f982010-05-19 07:28:01 +000056 br i1 undef, label %bb1, label %bb2
57
58bb1:
59; CHECK-NEXT: %bb1
60 %indvar = phi i32 [ %indvar.next, %bb1 ], [ 0, %entry ]
61 %tmp1 = shl i32 %indvar, 2
62 %gep1 = getelementptr i8* %ptr1, i32 %tmp1
Bob Wilson7a9ef442010-08-27 17:13:24 +000063 %tmp2 = call <4 x float> @llvm.arm.neon.vld1.v4f32(i8* %gep1, i32 1)
Evan Cheng9085f982010-05-19 07:28:01 +000064 %tmp3 = call <4 x float> @llvm.arm.neon.vmaxs.v4f32(<4 x float> <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00>, <4 x float> %tmp2)
65 %gep2 = getelementptr i8* %ptr2, i32 %tmp1
Bob Wilson7a9ef442010-08-27 17:13:24 +000066 call void @llvm.arm.neon.vst1.v4f32(i8* %gep2, <4 x float> %tmp3, i32 1)
Evan Cheng9085f982010-05-19 07:28:01 +000067 %indvar.next = add i32 %indvar, 1
68 %cond = icmp eq i32 %indvar.next, 10
69 br i1 %cond, label %bb2, label %bb1
70
71bb2:
72 ret void
73}
74
Dale Johannesen575cd142010-10-19 20:00:17 +000075; CHECK-NOT: LCPI1_0:
Evan Cheng9085f982010-05-19 07:28:01 +000076
Bob Wilson7a9ef442010-08-27 17:13:24 +000077declare <4 x float> @llvm.arm.neon.vld1.v4f32(i8*, i32) nounwind readonly
Evan Cheng9085f982010-05-19 07:28:01 +000078
Bob Wilson7a9ef442010-08-27 17:13:24 +000079declare void @llvm.arm.neon.vst1.v4f32(i8*, <4 x float>, i32) nounwind
Evan Cheng9085f982010-05-19 07:28:01 +000080
81declare <4 x float> @llvm.arm.neon.vmaxs.v4f32(<4 x float>, <4 x float>) nounwind readnone
Evan Chengc4af4632010-11-17 20:13:28 +000082
83; rdar://8241368
84; isel should not fold immediate into eor's which would have prevented LICM.
85define zeroext i16 @t3(i8 zeroext %data, i16 zeroext %crc) nounwind readnone {
86; CHECK: t3:
87bb.nph:
88; CHECK: bb.nph
89; CHECK: movw {{(r[0-9])|(lr)}}, #32768
Chris Lattnerb99e0002011-04-09 06:34:38 +000090; CHECK: movs {{(r[0-9]+)|(lr)}}, #0
Jakob Stoklund Olesend5b679c2011-04-30 01:37:52 +000091; CHECK: movw [[REGISTER:(r[0-9]+)|(lr)]], #16386
Chris Lattnerb99e0002011-04-09 06:34:38 +000092; CHECK: movw {{(r[0-9]+)|(lr)}}, #65534
93; CHECK: movt {{(r[0-9]+)|(lr)}}, #65535
Evan Chengc4af4632010-11-17 20:13:28 +000094 br label %bb
95
96bb: ; preds = %bb, %bb.nph
97; CHECK: bb
98; CHECK: eor.w {{(r[0-9])|(lr)}}, {{(r[0-9])|(lr)}}, [[REGISTER]]
99; CHECK: eor.w
100; CHECK-NOT: eor
101; CHECK: and
102 %data_addr.013 = phi i8 [ %data, %bb.nph ], [ %8, %bb ] ; <i8> [#uses=2]
103 %crc_addr.112 = phi i16 [ %crc, %bb.nph ], [ %crc_addr.2, %bb ] ; <i16> [#uses=3]
104 %i.011 = phi i8 [ 0, %bb.nph ], [ %7, %bb ] ; <i8> [#uses=1]
105 %0 = trunc i16 %crc_addr.112 to i8 ; <i8> [#uses=1]
106 %1 = xor i8 %data_addr.013, %0 ; <i8> [#uses=1]
107 %2 = and i8 %1, 1 ; <i8> [#uses=1]
108 %3 = icmp eq i8 %2, 0 ; <i1> [#uses=2]
109 %4 = xor i16 %crc_addr.112, 16386 ; <i16> [#uses=1]
110 %crc_addr.0 = select i1 %3, i16 %crc_addr.112, i16 %4 ; <i16> [#uses=1]
111 %5 = lshr i16 %crc_addr.0, 1 ; <i16> [#uses=2]
112 %6 = or i16 %5, -32768 ; <i16> [#uses=1]
113 %crc_addr.2 = select i1 %3, i16 %5, i16 %6 ; <i16> [#uses=2]
114 %7 = add i8 %i.011, 1 ; <i8> [#uses=2]
115 %8 = lshr i8 %data_addr.013, 1 ; <i8> [#uses=1]
116 %exitcond = icmp eq i8 %7, 8 ; <i1> [#uses=1]
117 br i1 %exitcond, label %bb8, label %bb
118
119bb8: ; preds = %bb
120 ret i16 %crc_addr.2
121}