blob: d5d32689e17c97f54f36d08f8631b091b3389291 [file] [log] [blame]
Andrew Trickc343c1e2011-03-15 00:37:00 +00001; RUN: opt < %s -scalar-evolution -analyze | FileCheck %s
Dan Gohmanac70cea2009-04-29 22:28:28 +00002
3; Convert (sext {-128,+,1}) to {sext(-128),+,sext(1)}, since the
4; trip count is within range where this is safe.
5
6target 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"
7target triple = "x86_64-unknown-linux-gnu"
8
9define void @foo(double* nocapture %x) nounwind {
10bb1.thread:
11 br label %bb1
12
13bb1: ; preds = %bb1, %bb1.thread
14 %i.0.reg2mem.0 = phi i64 [ -128, %bb1.thread ], [ %8, %bb1 ] ; <i64> [#uses=3]
Andrew Trickc343c1e2011-03-15 00:37:00 +000015; CHECK: %i.0.reg2mem.0
16; CHECK-NEXT: --> {-128,+,1}<%bb1> Exits: 127
Dan Gohmanac70cea2009-04-29 22:28:28 +000017 %0 = trunc i64 %i.0.reg2mem.0 to i8 ; <i8> [#uses=1]
Andrew Trickc343c1e2011-03-15 00:37:00 +000018; CHECK: %0
19; CHECK-NEXT: --> {-128,+,1}<%bb1> Exits: 127
Dan Gohmanac70cea2009-04-29 22:28:28 +000020 %1 = trunc i64 %i.0.reg2mem.0 to i9 ; <i8> [#uses=1]
Andrew Trickc343c1e2011-03-15 00:37:00 +000021; CHECK: %1
22; CHECK-NEXT: --> {-128,+,1}<%bb1> Exits: 127
Dan Gohmanac70cea2009-04-29 22:28:28 +000023 %2 = sext i9 %1 to i64 ; <i64> [#uses=1]
Andrew Trickc343c1e2011-03-15 00:37:00 +000024; CHECK: %2
25; CHECK-NEXT: --> {-128,+,1}<nsw><%bb1> Exits: 127
Dan Gohmanac70cea2009-04-29 22:28:28 +000026 %3 = getelementptr double* %x, i64 %2 ; <double*> [#uses=1]
27 %4 = load double* %3, align 8 ; <double> [#uses=1]
Dan Gohmanae3a0be2009-06-04 22:49:04 +000028 %5 = fmul double %4, 3.900000e+00 ; <double> [#uses=1]
Dan Gohmanac70cea2009-04-29 22:28:28 +000029 %6 = sext i8 %0 to i64 ; <i64> [#uses=1]
30 %7 = getelementptr double* %x, i64 %6 ; <double*> [#uses=1]
31 store double %5, double* %7, align 8
32 %8 = add i64 %i.0.reg2mem.0, 1 ; <i64> [#uses=2]
33 %9 = icmp sgt i64 %8, 127 ; <i1> [#uses=1]
34 br i1 %9, label %return, label %bb1
35
36return: ; preds = %bb1
37 ret void
38}