Andrew Trick | 429e9ed | 2014-02-26 16:31:56 +0000 | [diff] [blame] | 1 | ; RUN: opt < %s -loop-reduce -S | FileCheck %s |
| 2 | target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" |
| 3 | target triple = "x86_64-apple-macosx10.9.0" |
| 4 | |
| 5 | ; LSR shouldn't reuse IV if the resultant offset is not valid for the operand type. |
| 6 | ; CHECK-NOT: trunc i32 %.ph to i8 |
| 7 | |
| 8 | %struct.anon = type { i32, i32, i32 } |
| 9 | |
| 10 | @c = global i32 1, align 4 |
| 11 | @.str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1 |
| 12 | @b = common global i32 0, align 4 |
| 13 | @a = common global %struct.anon zeroinitializer, align 4 |
| 14 | @e = common global %struct.anon zeroinitializer, align 4 |
| 15 | @d = common global i32 0, align 4 |
| 16 | @f = common global i32 0, align 4 |
| 17 | @g = common global i32 0, align 4 |
| 18 | @h = common global i32 0, align 4 |
| 19 | |
| 20 | ; Function Attrs: nounwind optsize ssp uwtable |
| 21 | define i32 @main() #0 { |
| 22 | entry: |
David Blaikie | f72d05b | 2015-03-13 18:20:45 +0000 | [diff] [blame] | 23 | %0 = load i32, i32* getelementptr inbounds (%struct.anon, %struct.anon* @a, i64 0, i32 0), align 4, !tbaa !1 |
Andrew Trick | 429e9ed | 2014-02-26 16:31:56 +0000 | [diff] [blame] | 24 | %tobool7.i = icmp eq i32 %0, 0 |
David Blaikie | f72d05b | 2015-03-13 18:20:45 +0000 | [diff] [blame] | 25 | %.promoted.i = load i32, i32* getelementptr inbounds (%struct.anon, %struct.anon* @a, i64 0, i32 2), align 4, !tbaa !6 |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 26 | %f.promoted.i = load i32, i32* @f, align 4, !tbaa !7 |
Andrew Trick | 429e9ed | 2014-02-26 16:31:56 +0000 | [diff] [blame] | 27 | br label %for.body6.i.outer |
| 28 | |
| 29 | for.body6.i.outer: ; preds = %entry, %lor.end.i |
| 30 | %.ph = phi i32 [ %add.i, %lor.end.i ], [ 0, %entry ] |
| 31 | %or1512.i.ph = phi i32 [ %or15.i, %lor.end.i ], [ %f.promoted.i, %entry ] |
| 32 | %or1410.i.ph = phi i32 [ %or14.i, %lor.end.i ], [ %.promoted.i, %entry ] |
| 33 | %p.addr.16.i.ph = phi i8 [ %inc10.i, %lor.end.i ], [ -128, %entry ] |
| 34 | br i1 %tobool7.i, label %if.end9.i, label %lbl.loopexit.i |
| 35 | |
| 36 | lbl.loopexit.i: ; preds = %for.body6.i.outer, %lbl.loopexit.i |
| 37 | br label %lbl.loopexit.i |
| 38 | |
| 39 | if.end9.i: ; preds = %for.body6.i.outer |
| 40 | %inc10.i = add i8 %p.addr.16.i.ph, 1 |
| 41 | %tobool12.i = icmp eq i8 %p.addr.16.i.ph, 0 |
| 42 | br i1 %tobool12.i, label %lor.rhs.i, label %lor.end.i |
| 43 | |
| 44 | lor.rhs.i: ; preds = %if.end9.i |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 45 | %1 = load i32, i32* @b, align 4, !tbaa !7 |
Andrew Trick | 429e9ed | 2014-02-26 16:31:56 +0000 | [diff] [blame] | 46 | %dec.i = add nsw i32 %1, -1 |
| 47 | store i32 %dec.i, i32* @b, align 4, !tbaa !7 |
| 48 | %tobool13.i = icmp ne i32 %1, 0 |
| 49 | br label %lor.end.i |
| 50 | |
| 51 | lor.end.i: ; preds = %lor.rhs.i, %if.end9.i |
| 52 | %2 = phi i1 [ true, %if.end9.i ], [ %tobool13.i, %lor.rhs.i ] |
| 53 | %lor.ext.i = zext i1 %2 to i32 |
| 54 | %or14.i = or i32 %lor.ext.i, %or1410.i.ph |
| 55 | %or15.i = or i32 %or14.i, %or1512.i.ph |
| 56 | %add.i = add nsw i32 %.ph, 2 |
| 57 | %cmp.i = icmp slt i32 %add.i, 21 |
| 58 | br i1 %cmp.i, label %for.body6.i.outer, label %fn1.exit |
| 59 | |
| 60 | fn1.exit: ; preds = %lor.end.i |
| 61 | store i32 0, i32* @g, align 4, !tbaa !7 |
David Blaikie | f72d05b | 2015-03-13 18:20:45 +0000 | [diff] [blame] | 62 | store i32 %or14.i, i32* getelementptr inbounds (%struct.anon, %struct.anon* @a, i64 0, i32 2), align 4, !tbaa !6 |
Andrew Trick | 429e9ed | 2014-02-26 16:31:56 +0000 | [diff] [blame] | 63 | store i32 %or15.i, i32* @f, align 4, !tbaa !7 |
David Blaikie | f72d05b | 2015-03-13 18:20:45 +0000 | [diff] [blame] | 64 | store i32 %add.i, i32* getelementptr inbounds (%struct.anon, %struct.anon* @e, i64 0, i32 1), align 4, !tbaa !8 |
Andrew Trick | 429e9ed | 2014-02-26 16:31:56 +0000 | [diff] [blame] | 65 | store i32 0, i32* @h, align 4, !tbaa !7 |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 66 | %3 = load i32, i32* @b, align 4, !tbaa !7 |
David Blaikie | 23af648 | 2015-04-16 23:24:18 +0000 | [diff] [blame] | 67 | %call1 = tail call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %3) #2 |
Andrew Trick | 429e9ed | 2014-02-26 16:31:56 +0000 | [diff] [blame] | 68 | ret i32 0 |
| 69 | } |
| 70 | |
| 71 | ; Function Attrs: nounwind optsize |
| 72 | declare i32 @printf(i8* nocapture readonly, ...) #1 |
| 73 | |
| 74 | attributes #0 = { nounwind optsize ssp uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } |
| 75 | attributes #1 = { nounwind optsize "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } |
| 76 | attributes #2 = { nounwind optsize } |
| 77 | |
| 78 | !llvm.ident = !{!0} |
| 79 | |
Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 80 | !0 = !{!"clang version 3.5 "} |
| 81 | !1 = !{!2, !3, i64 0} |
| 82 | !2 = !{!"", !3, i64 0, !3, i64 4, !3, i64 8} |
| 83 | !3 = !{!"int", !4, i64 0} |
| 84 | !4 = !{!"omnipotent char", !5, i64 0} |
| 85 | !5 = !{!"Simple C/C++ TBAA"} |
| 86 | !6 = !{!2, !3, i64 8} |
| 87 | !7 = !{!3, !3, i64 0} |
| 88 | !8 = !{!2, !3, i64 4} |