]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/Transforms/LICM/constexpr.ll
Vendor import of llvm release_40 branch r292009:
[FreeBSD/FreeBSD.git] / test / Transforms / LICM / constexpr.ll
1 ; RUN: opt < %s -S -basicaa -licm | FileCheck %s
2 ; RUN: opt -aa-pipeline=basic-aa -passes='lcssa,require<aa>,require<targetir>,require<scalar-evolution>,require<opt-remark-emit>,loop(licm)' < %s -S | FileCheck %s
3 ; This fixes PR22460
4
5 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
6 target triple = "x86_64-pc-windows-msvc"
7
8 @in = internal unnamed_addr global i32* null, align 8
9 @out = internal unnamed_addr global i32* null, align 8
10
11 ; CHECK-LABEL: @bar
12 ; CHECK: entry:
13 ; CHECK: load i64, i64* bitcast (i32** @in to i64*)
14 ; CHECK: do.body:
15 ; CHECK-NOT: load
16
17 define i64 @bar(i32 %N) {
18 entry:
19   br label %do.body
20
21 do.body:                                          ; preds = %l2, %entry
22   %i.0 = phi i32 [ 0, %entry ], [ %inc, %l2 ]
23   %total = phi i64 [ 0, %entry ], [ %next, %l2 ]
24   %c = icmp eq i32 %N, 6
25   br i1 %c, label %l1, label %do.body.l2_crit_edge
26
27 do.body.l2_crit_edge:                             ; preds = %do.body
28   %inval.pre = load i32*, i32** @in, align 8
29   br label %l2
30
31 l1:                                               ; preds = %do.body
32   %v1 = load i64, i64* bitcast (i32** @in to i64*), align 8
33   store i64 %v1, i64* bitcast (i32** @out to i64*), align 8
34   %0 = inttoptr i64 %v1 to i32*
35   br label %l2
36
37 l2:                                               ; preds = %do.body.l2_crit_edge, %l1
38   %inval = phi i32* [ %inval.pre, %do.body.l2_crit_edge ], [ %0, %l1 ]
39   %int = ptrtoint i32* %inval to i64
40   %next = add i64 %total, %int
41   %inc = add nsw i32 %i.0, 1
42   %cmp = icmp slt i32 %inc, %N
43   br i1 %cmp, label %do.body, label %do.end
44
45 do.end:                                           ; preds = %l2
46   ret i64 %total
47 }