Dan Gohman | 3c7d308 | 2009-09-11 18:01:28 +0000 | [diff] [blame] | 1 | ; RUN: opt < %s -indvars -disable-output |
Dan Gohman | 3cc96f3 | 2009-04-22 16:11:16 +0000 | [diff] [blame] | 2 | ; PR4009 |
Dan Gohman | 6860e16 | 2009-04-23 15:16:49 +0000 | [diff] [blame] | 3 | ; PR4038 |
Dan Gohman | 3cc96f3 | 2009-04-22 16:11:16 +0000 | [diff] [blame] | 4 | |
| 5 | target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32" |
| 6 | target triple = "i386-pc-linux-gnu" |
| 7 | |
| 8 | define void @safe_bcopy(i8* %to) nounwind { |
| 9 | entry: |
| 10 | %cmp11 = icmp ult i8* %to, null ; <i1> [#uses=1] |
| 11 | br i1 %cmp11, label %loop, label %return |
| 12 | |
| 13 | return: ; preds = %entry |
| 14 | ret void |
| 15 | |
| 16 | loop: ; preds = %loop, %if.else |
| 17 | %pn = phi i8* [ %ge, %loop ], [ null, %entry ] ; <i8*> [#uses=1] |
| 18 | %cp = ptrtoint i8* %to to i32 ; <i32> [#uses=1] |
| 19 | %su = sub i32 0, %cp ; <i32> [#uses=1] |
| 20 | %ge = getelementptr i8* %pn, i32 %su ; <i8*> [#uses=2] |
| 21 | tail call void @bcopy(i8* %ge) nounwind |
| 22 | br label %loop |
| 23 | } |
| 24 | |
Dan Gohman | 6860e16 | 2009-04-23 15:16:49 +0000 | [diff] [blame] | 25 | define void @safe_bcopy_4038(i8* %from, i8* %to, i32 %size) nounwind { |
| 26 | entry: |
| 27 | br i1 false, label %if.else, label %if.then12 |
| 28 | |
| 29 | if.then12: ; preds = %entry |
| 30 | ret void |
| 31 | |
| 32 | if.else: ; preds = %entry |
| 33 | %sub.ptr.rhs.cast40 = ptrtoint i8* %from to i32 ; <i32> [#uses=1] |
| 34 | br label %if.end54 |
| 35 | |
| 36 | if.end54: ; preds = %if.end54, %if.else |
| 37 | %sub.ptr4912.pn = phi i8* [ %sub.ptr4912, %if.end54 ], [ null, %if.else ] ; <i8*> [#uses=1] |
| 38 | %sub.ptr7 = phi i8* [ %sub.ptr, %if.end54 ], [ null, %if.else ] ; <i8*> [#uses=2] |
| 39 | %sub.ptr.rhs.cast46.pn = ptrtoint i8* %from to i32 ; <i32> [#uses=1] |
| 40 | %sub.ptr.lhs.cast45.pn = ptrtoint i8* %to to i32 ; <i32> [#uses=1] |
| 41 | %sub.ptr.sub47.pn = sub i32 %sub.ptr.rhs.cast46.pn, %sub.ptr.lhs.cast45.pn ; <i32> [#uses=1] |
| 42 | %sub.ptr4912 = getelementptr i8* %sub.ptr4912.pn, i32 %sub.ptr.sub47.pn ; <i8*> [#uses=2] |
Dan Gohman | 1ba5260 | 2009-04-23 15:22:28 +0000 | [diff] [blame] | 43 | tail call void @bcopy_4038(i8* %sub.ptr4912, i8* %sub.ptr7, i32 0) nounwind |
Dan Gohman | 6860e16 | 2009-04-23 15:16:49 +0000 | [diff] [blame] | 44 | %sub.ptr = getelementptr i8* %sub.ptr7, i32 %sub.ptr.rhs.cast40 ; <i8*> [#uses=1] |
| 45 | br label %if.end54 |
| 46 | } |
| 47 | |
Dan Gohman | 3cc96f3 | 2009-04-22 16:11:16 +0000 | [diff] [blame] | 48 | declare void @bcopy(i8* nocapture) nounwind |
Dan Gohman | 1ba5260 | 2009-04-23 15:22:28 +0000 | [diff] [blame] | 49 | |
| 50 | declare void @bcopy_4038(i8*, i32) nounwind |