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