1 ; 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
6 ; The generated code is no where near ideal. It's not recognizing the two
7 ; constantpool entries being loaded can be merged into one.
9 @GV = external global i32 ; <i32*> [#uses=2]
11 define void @t1(i32* nocapture %vals, i32 %c) nounwind {
15 %0 = icmp eq i32 %c, 0 ; <i1> [#uses=1]
16 br i1 %0, label %return, label %bb.nph
18 bb.nph: ; preds = %entry
20 ; CHECK: ldr.n r2, LCPI0_0
28 ; PIC: ldr.n r2, LCPI0_0
36 %.pre = load i32* @GV, align 4 ; <i32> [#uses=1]
39 bb: ; preds = %bb, %bb.nph
40 %1 = phi i32 [ %.pre, %bb.nph ], [ %3, %bb ] ; <i32> [#uses=1]
41 %i.03 = phi i32 [ 0, %bb.nph ], [ %4, %bb ] ; <i32> [#uses=2]
42 %scevgep = getelementptr i32* %vals, i32 %i.03 ; <i32*> [#uses=1]
43 %2 = load i32* %scevgep, align 4 ; <i32> [#uses=1]
44 %3 = add nsw i32 %1, %2 ; <i32> [#uses=2]
45 store i32 %3, i32* @GV, align 4
46 %4 = add i32 %i.03, 1 ; <i32> [#uses=2]
47 %exitcond = icmp eq i32 %4, %c ; <i1> [#uses=1]
48 br i1 %exitcond, label %return, label %bb
50 return: ; preds = %bb, %entry
55 define void @t2(i8* %ptr1, i8* %ptr2) nounwind {
58 ; CHECK: mov.w r3, #1065353216
59 ; CHECK: vdup.32 q{{.*}}, r3
60 br i1 undef, label %bb1, label %bb2
64 %indvar = phi i32 [ %indvar.next, %bb1 ], [ 0, %entry ]
65 %tmp1 = shl i32 %indvar, 2
66 %gep1 = getelementptr i8* %ptr1, i32 %tmp1
67 %tmp2 = call <4 x float> @llvm.arm.neon.vld1.v4f32(i8* %gep1, i32 1)
68 %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)
69 %gep2 = getelementptr i8* %ptr2, i32 %tmp1
70 call void @llvm.arm.neon.vst1.v4f32(i8* %gep2, <4 x float> %tmp3, i32 1)
71 %indvar.next = add i32 %indvar, 1
72 %cond = icmp eq i32 %indvar.next, 10
73 br i1 %cond, label %bb2, label %bb1
81 declare <4 x float> @llvm.arm.neon.vld1.v4f32(i8*, i32) nounwind readonly
83 declare void @llvm.arm.neon.vst1.v4f32(i8*, <4 x float>, i32) nounwind
85 declare <4 x float> @llvm.arm.neon.vmaxs.v4f32(<4 x float>, <4 x float>) nounwind readnone
88 ; isel should not fold immediate into eor's which would have prevented LICM.
89 define zeroext i16 @t3(i8 zeroext %data, i16 zeroext %crc) nounwind readnone {
93 ; CHECK: movw {{(r[0-9])|(lr)}}, #32768
94 ; CHECK: movs {{(r[0-9])|(lr)}}, #8
95 ; CHECK: movw [[REGISTER:(r[0-9])|(lr)]], #16386
96 ; CHECK: movw {{(r[0-9])|(lr)}}, #65534
97 ; CHECK: movt {{(r[0-9])|(lr)}}, #65535
100 bb: ; preds = %bb, %bb.nph
102 ; CHECK: eor.w {{(r[0-9])|(lr)}}, {{(r[0-9])|(lr)}}, [[REGISTER]]
106 %data_addr.013 = phi i8 [ %data, %bb.nph ], [ %8, %bb ] ; <i8> [#uses=2]
107 %crc_addr.112 = phi i16 [ %crc, %bb.nph ], [ %crc_addr.2, %bb ] ; <i16> [#uses=3]
108 %i.011 = phi i8 [ 0, %bb.nph ], [ %7, %bb ] ; <i8> [#uses=1]
109 %0 = trunc i16 %crc_addr.112 to i8 ; <i8> [#uses=1]
110 %1 = xor i8 %data_addr.013, %0 ; <i8> [#uses=1]
111 %2 = and i8 %1, 1 ; <i8> [#uses=1]
112 %3 = icmp eq i8 %2, 0 ; <i1> [#uses=2]
113 %4 = xor i16 %crc_addr.112, 16386 ; <i16> [#uses=1]
114 %crc_addr.0 = select i1 %3, i16 %crc_addr.112, i16 %4 ; <i16> [#uses=1]
115 %5 = lshr i16 %crc_addr.0, 1 ; <i16> [#uses=2]
116 %6 = or i16 %5, -32768 ; <i16> [#uses=1]
117 %crc_addr.2 = select i1 %3, i16 %5, i16 %6 ; <i16> [#uses=2]
118 %7 = add i8 %i.011, 1 ; <i8> [#uses=2]
119 %8 = lshr i8 %data_addr.013, 1 ; <i8> [#uses=1]
120 %exitcond = icmp eq i8 %7, 8 ; <i1> [#uses=1]
121 br i1 %exitcond, label %bb8, label %bb