1 ; RUN: opt %loadPolly %defaultOpts -polly-codegen -enable-polly-vector -dce -S %s | FileCheck %s
2 ; Obtained from C source as:
3 ; clang -S -emit-llvm -O0 pr45902.c
4 ; opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars -instnamer pr45902.s > pr45902.ll
6 ; ModuleID = 'pr45902.s'
8 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
9 target triple = "x86_64-unknown-linux-gnu"
11 @a = common global [128 x i16] zeroinitializer, align 16
12 @res = common global [128 x i16] zeroinitializer, align 16
14 define i32 @main1() nounwind uwtable {
18 for.cond: ; preds = %for.inc, %entry
19 %indvar = phi i64 [ %indvar.next, %for.inc ], [ 0, %entry ]
20 %tmp = mul i64 %indvar, 4
21 %tmp11 = add i64 %tmp, 3
22 %arrayidx41 = getelementptr [128 x i16]* @res, i64 0, i64 %tmp11
23 %arrayidx33 = getelementptr [128 x i16]* @a, i64 0, i64 %tmp11
24 %tmp12 = add i64 %tmp, 2
25 %arrayidx29 = getelementptr [128 x i16]* @res, i64 0, i64 %tmp12
26 %arrayidx21 = getelementptr [128 x i16]* @a, i64 0, i64 %tmp12
27 %tmp13 = add i64 %tmp, 1
28 %arrayidx17 = getelementptr [128 x i16]* @res, i64 0, i64 %tmp13
29 %arrayidx9 = getelementptr [128 x i16]* @a, i64 0, i64 %tmp13
30 %arrayidx6 = getelementptr [128 x i16]* @res, i64 0, i64 %tmp
31 %arrayidx = getelementptr [128 x i16]* @a, i64 0, i64 %tmp
32 %exitcond = icmp ne i64 %indvar, 8
33 br i1 %exitcond, label %for.body, label %for.end
35 for.body: ; preds = %for.cond
36 %tmp2 = load i16* %arrayidx, align 8
37 %conv = sext i16 %tmp2 to i32
38 %shr1 = lshr i32 %conv, 8
39 %conv3 = trunc i32 %shr1 to i16
40 store i16 %conv3, i16* %arrayidx6, align 8
41 %tmp10 = load i16* %arrayidx9, align 2
42 %conv11 = sext i16 %tmp10 to i32
43 %shr123 = lshr i32 %conv11, 8
44 %conv13 = trunc i32 %shr123 to i16
45 store i16 %conv13, i16* %arrayidx17, align 2
46 %tmp22 = load i16* %arrayidx21, align 4
47 %conv23 = sext i16 %tmp22 to i32
48 %shr246 = lshr i32 %conv23, 8
49 %conv25 = trunc i32 %shr246 to i16
50 store i16 %conv25, i16* %arrayidx29, align 4
51 %tmp34 = load i16* %arrayidx33, align 2
52 %conv35 = sext i16 %tmp34 to i32
53 %shr369 = lshr i32 %conv35, 8
54 %conv37 = trunc i32 %shr369 to i16
55 store i16 %conv37, i16* %arrayidx41, align 2
58 for.inc: ; preds = %for.body
59 %indvar.next = add i64 %indvar, 1
62 for.end: ; preds = %for.cond
66 define i32 @main() nounwind uwtable {
70 for.cond: ; preds = %for.inc, %entry
71 %indvar1 = phi i64 [ %indvar.next2, %for.inc ], [ 0, %entry ]
72 %arrayidx = getelementptr [128 x i16]* @a, i64 0, i64 %indvar1
73 %conv = trunc i64 %indvar1 to i16
74 %exitcond = icmp ne i64 %indvar1, 128
75 br i1 %exitcond, label %for.body, label %for.end
77 for.body: ; preds = %for.cond
78 store i16 %conv, i16* %arrayidx, align 2
81 for.inc: ; preds = %for.body
82 %indvar.next2 = add i64 %indvar1, 1
85 for.end: ; preds = %for.cond
86 %call = call i32 @main1()
89 for.cond4: ; preds = %for.inc21, %for.end
90 %indvar = phi i64 [ %indvar.next, %for.inc21 ], [ 0, %for.end ]
91 %arrayidx16 = getelementptr [128 x i16]* @a, i64 0, i64 %indvar
92 %arrayidx11 = getelementptr [128 x i16]* @res, i64 0, i64 %indvar
93 %i.1 = trunc i64 %indvar to i32
94 %cmp6 = icmp slt i32 %i.1, 128
95 br i1 %cmp6, label %for.body8, label %for.end24
97 for.body8: ; preds = %for.cond4
98 %tmp12 = load i16* %arrayidx11, align 2
99 %conv13 = sext i16 %tmp12 to i32
100 %tmp17 = load i16* %arrayidx16, align 2
101 %conv18 = sext i16 %tmp17 to i32
102 %shr = ashr i32 %conv18, 8
103 %cmp19 = icmp eq i32 %conv13, %shr
104 br i1 %cmp19, label %if.end, label %if.then
106 if.then: ; preds = %for.body8
107 call void @abort() noreturn nounwind
110 if.end: ; preds = %for.body8
113 for.inc21: ; preds = %if.end
114 %indvar.next = add i64 %indvar, 1
117 for.end24: ; preds = %for.cond4
121 declare void @abort() noreturn nounwind