[AArch64] Fix bug in prolog clobbering live reg when shrink wrapping.
[oota-llvm.git] / test / CodeGen / AArch64 / fast-isel-address-extends.ll
1 ; RUN: llc %s -o - -O0 -verify-machineinstrs -fast-isel=true | FileCheck %s
2
3 target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
4 target triple = "arm64-apple-ios8.0.0"
5
6 ; This test was trying to fold the sext %tmp142 in to the address arithmetic in %sunkaddr1.
7 ; This was incorrect as %.mux isn't available in the last bb.
8
9 ; CHECK: sxtw [[REG:x[0-9]+]]
10 ; CHECK: strh wzr, {{\[}}[[REG]], {{.*}}, lsl #1]
11
12 ; Function Attrs: nounwind optsize ssp
13 define void @EdgeLoop(i32 %dir, i32 %edge, i32 %width, i16* %tmp89, i32 %tmp136, i16 %tmp144) #0 {
14 bb:
15   %tmp2 = icmp eq i32 %dir, 0
16   %.mux = select i1 %tmp2, i32 %width, i32 1
17   %tmp142 = sext i32 %.mux to i64
18   %tmp151 = shl nsw i64 %tmp142, 1
19   %tmp153 = getelementptr inbounds i16, i16* %tmp89, i64 %tmp151
20   %tmp154 = load i16, i16* %tmp153, align 2
21   %tmp155 = zext i16 %tmp154 to i32
22   br i1 %tmp2, label %bb225, label %bb212
23
24 bb212:                                            ; preds = %bb
25   store i16 %tmp144, i16* %tmp89, align 2
26   ret void
27
28 bb225:                                            ; preds = %bb
29   %tmp248 = trunc i32 %tmp155 to i16
30   store i16 %tmp248, i16* %tmp89, align 2
31   %sunkaddr = ptrtoint i16* %tmp89 to i64
32   %sunkaddr1 = mul i64 %tmp142, 2
33   %sunkaddr2 = add i64 %sunkaddr, %sunkaddr1
34   %sunkaddr3 = inttoptr i64 %sunkaddr2 to i16*
35   store i16 0, i16* %sunkaddr3, align 2
36   ret void
37 }
38
39 attributes #0 = { nounwind optsize ssp }