widen-nsw.ll 1.3 KB

1234567891011121314151617181920212223242526272829
  1. ; RUN: opt < %s -indvars -S | FileCheck %s
  2. target 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-n8:16:32:64-S128"
  3. target triple = "x86_64-apple-macosx"
  4. ; CHECK-LABEL: @test1
  5. ; CHECK: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  6. define i32 @test1(i32* %a) #0 {
  7. entry:
  8. br label %for.cond
  9. for.cond: ; preds = %for.body, %entry
  10. %sum.0 = phi i32 [ 0, %entry ], [ %add, %for.body ]
  11. %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
  12. %cmp = icmp slt i32 %i.0, 1000
  13. br i1 %cmp, label %for.body, label %for.end
  14. for.body: ; preds = %for.cond
  15. %idxprom = sext i32 %i.0 to i64
  16. %arrayidx = getelementptr inbounds i32, i32* %a, i64 %idxprom
  17. %0 = load i32, i32* %arrayidx, align 4
  18. %add = add nsw i32 %sum.0, %0
  19. %inc = add nsw i32 %i.0, 1
  20. br label %for.cond
  21. for.end: ; preds = %for.cond
  22. ret i32 %sum.0
  23. }
  24. attributes #0 = { nounwind ssp uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }