1; RUN: opt %loadPolly -analyze -polly-scops -polly-invariant-load-hoisting=true %s | FileCheck %s --check-prefix=SCOP
2; RUN: opt %loadPolly -S -polly-codegen -polly-invariant-load-hoisting=true %s | FileCheck %s
3;
4; The offset of the %tmp1 load wrt. to %buff (62 bytes) is not divisible
5; by the type size (i32 = 4 bytes), thus we will have to represent %buff
6; with a smaller type. In this case i16 is sufficient to represent the
7; 62 byte offset accurately.
8;
9; SCOP:    Invariant Accesses: {
10; SCOP:            ReadAccess :=	[Reduction Type: NONE] [Scalar: 0]
11; SCOP:                { Stmt_if_end_6[] -> MemRef_buff[o0] : 31 <= o0 <= 32 };
12; SCOP:            Execution Context: {  :  }
13; SCOP:    }
14; SCOP:    Arrays {
15; SCOP:        i16 MemRef_buff[*]; // Element size 2
16; SCOP:        i32 MemRef_key_0; // Element size 4
17; SCOP:    }
18;
19; CHECK-LABEL: polly.preload.begin:
20; CHECK-NEXT:    %polly.access.cast.buff = bitcast i8* %buff to i16*
21; CHECK-NEXT:    %polly.access.buff = getelementptr i16, i16* %polly.access.cast.buff, i64 31
22; CHECK-NEXT:    %polly.access.buff.cast = bitcast i16* %polly.access.buff to i32*
23; CHECK-NEXT:    %polly.access.buff.load = load i32, i32* %polly.access.buff.cast, align 4
24; CHECK-NEXT:    store i32 %polly.access.buff.load, i32* %tmp1.preload.s2a
25;
26target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
27
28; Function Attrs: nounwind uwtable
29define void @sudecrypt(i8* %buff) #0 {
30entry:
31  br i1 undef, label %cleanup, label %if.end
32
33if.end:                                           ; preds = %entry
34  br i1 undef, label %if.end.6, label %if.then.5
35
36if.then.5:                                        ; preds = %if.end
37  unreachable
38
39if.end.6:                                         ; preds = %if.end
40  %add.ptr = getelementptr inbounds i8, i8* %buff, i64 62
41  %tmp = bitcast i8* %add.ptr to i32*
42  %tmp1 = load i32, i32* %tmp, align 4, !tbaa !1
43  br i1 false, label %if.then.13, label %switch.early.test
44
45switch.early.test:                                ; preds = %if.end.6
46  switch i32 0, label %if.end.16 [
47    i32 956, label %if.then.13
48    i32 520, label %if.then.13
49  ]
50
51if.then.13:                                       ; preds = %switch.early.test, %switch.early.test, %if.end.6
52  br label %if.end.16
53
54if.end.16:                                        ; preds = %if.then.13, %switch.early.test
55  %key.0 = phi i32 [ undef, %if.then.13 ], [ 0, %switch.early.test ]
56  br i1 undef, label %if.end.34, label %if.then.19
57
58if.then.19:                                       ; preds = %if.end.16
59  unreachable
60
61if.end.34:                                        ; preds = %if.end.16
62  unreachable
63
64cleanup:                                          ; preds = %entry
65  ret void
66}
67
68attributes #0 = { nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
69
70!llvm.ident = !{!0}
71
72!0 = !{!"clang version 3.8.0 (trunk 250010) (llvm/trunk 250018)"}
73!1 = !{!2, !2, i64 0}
74!2 = !{!"int", !3, i64 0}
75!3 = !{!"omnipotent char", !4, i64 0}
76!4 = !{!"Simple C/C++ TBAA"}
77