50 lines
2 KiB
LLVM
50 lines
2 KiB
LLVM
; ModuleID = 'sumSquares.c'
|
|
source_filename = "sumSquares.c"
|
|
target datalayout = "e-m:e-p:32:16-i16:16-i32:16-i64:16-f32:16-f64:16-a:8-n8:16-S8"
|
|
target triple = "w65816"
|
|
|
|
; Function Attrs: nofree norecurse nosync nounwind memory(none)
|
|
define dso_local i32 @sumSquares(i16 noundef zeroext %n) local_unnamed_addr #0 {
|
|
entry:
|
|
%cmp.not6 = icmp eq i16 %n, 0
|
|
br i1 %cmp.not6, label %for.cond.cleanup, label %for.body.preheader
|
|
|
|
for.body.preheader: ; preds = %entry
|
|
%0 = add i16 %n, 1
|
|
%umax = tail call i16 @llvm.umax.i16(i16 %0, i16 2)
|
|
br label %for.body
|
|
|
|
for.cond.cleanup: ; preds = %for.body, %entry
|
|
%total.0.lcssa = phi i32 [ 0, %entry ], [ %add, %for.body ]
|
|
ret i32 %total.0.lcssa
|
|
|
|
for.body: ; preds = %for.body.preheader, %for.body
|
|
%i.08 = phi i16 [ %inc, %for.body ], [ 1, %for.body.preheader ]
|
|
%total.07 = phi i32 [ %add, %for.body ], [ 0, %for.body.preheader ]
|
|
%conv = zext i16 %i.08 to i32
|
|
%mul = mul nuw i32 %conv, %conv
|
|
%add = add i32 %mul, %total.07
|
|
%inc = add nuw i16 %i.08, 1
|
|
%exitcond = icmp eq i16 %inc, %umax
|
|
br i1 %exitcond, label %for.cond.cleanup, label %for.body, !llvm.loop !7
|
|
}
|
|
|
|
; Function Attrs: nocallback nocreateundeforpoison nofree nosync nounwind speculatable willreturn memory(none)
|
|
declare i16 @llvm.umax.i16(i16, i16) #1
|
|
|
|
attributes #0 = { nofree norecurse nosync nounwind memory(none) "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
|
|
attributes #1 = { nocallback nocreateundeforpoison nofree nosync nounwind speculatable willreturn memory(none) }
|
|
|
|
!llvm.module.flags = !{!0, !1}
|
|
!llvm.ident = !{!2}
|
|
!llvm.errno.tbaa = !{!3}
|
|
|
|
!0 = !{i32 1, !"wchar_size", i32 2}
|
|
!1 = !{i32 7, !"frame-pointer", i32 2}
|
|
!2 = !{!"clang version 23.0.0git (https://github.com/llvm-mos/llvm-mos.git c798c31416f72b395c658b5502d281a162387ab1)"}
|
|
!3 = !{!4, !4, i64 0}
|
|
!4 = !{!"int", !5, i64 0}
|
|
!5 = !{!"omnipotent char", !6, i64 0}
|
|
!6 = !{!"Simple C/C++ TBAA"}
|
|
!7 = distinct !{!7, !8}
|
|
!8 = !{!"llvm.loop.mustprogress"}
|