Skip to content

Instantly share code, notes, and snippets.

@archshift
Created August 4, 2020 21:34
Show Gist options
  • Save archshift/63c34e40145c93a3fc3b514badc09c60 to your computer and use it in GitHub Desktop.
Save archshift/63c34e40145c93a3fc3b514badc09c60 to your computer and use it in GitHub Desktop.
; ModuleID = '<stdin>'
source_filename = "sqrt.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @msan.module_ctor, i8* null }]
@__msan_track_origins = weak_odr local_unnamed_addr constant i32 2
; Function Attrs: norecurse nounwind readnone uwtable
define dso_local noundef i32 @_Z4sqrti(i32 noundef %x) local_unnamed_addr #0 {
entry:
%div21 = sdiv i32 %x, 2
%conv22 = sext i32 %div21 to i64
%mul23 = mul nsw i64 %conv22, %conv22
%conv2 = sext i32 %x to i64
%sub324 = sub nsw i64 %mul23, %conv2
%0 = icmp eq i64 %sub324, 0
br i1 %0, label %if.then, label %if.end
if.then: ; preds = %if.end, %entry
%add.lcssa = phi i32 [ %div21, %entry ], [ %add, %if.end ]
ret i32 %add.lcssa
if.end: ; preds = %entry, %if.end
%sub331 = phi i64 [ %sub3, %if.end ], [ %sub324, %entry ]
%add30 = phi i32 [ %add, %if.end ], [ %div21, %entry ]
%min_r.029 = phi i32 [ %min_r.1, %if.end ], [ 0, %entry ]
%max_r.028 = phi i32 [ %max_r.1, %if.end ], [ %x, %entry ]
%cmp4 = icmp sgt i64 %sub331, 0
%max_r.1 = select i1 %cmp4, i32 %add30, i32 %max_r.028
%min_r.1 = select i1 %cmp4, i32 %min_r.029, i32 %add30
%sub = sub nsw i32 %max_r.1, %min_r.1
%div = sdiv i32 %sub, 2
%add = add nsw i32 %div, %min_r.1
%conv = sext i32 %add to i64
%mul = mul nsw i64 %conv, %conv
%sub3 = sub nsw i64 %mul, %conv2
%cmp = icmp eq i64 %sub331, %sub3
%tobool.not = icmp eq i64 %sub3, 0
%or.cond = or i1 %tobool.not, %cmp
br i1 %or.cond, label %if.then, label %if.end, !llvm.loop !2
}
declare void @__msan_init() local_unnamed_addr
define internal void @msan.module_ctor() {
tail call void @__msan_init()
ret void
}
attributes #0 = { norecurse nounwind readnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
!llvm.module.flags = !{!0}
!llvm.ident = !{!1}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{!"clang version 12.0.0 (git@github.com:archshift/llvm-project 7dc09d2f6c94490d994be0e8cf5432290f0e2fd7)"}
!2 = distinct !{!2, !3}
!3 = !{!"llvm.loop.unroll.disable"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment