-
-
Save rhysd/f9e20edb9171d1c6116b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; ModuleID = 'samples/sqrt2.dcs' | |
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" | |
target triple = "x86_64-apple-darwin15.3.0" | |
@const.unit = private unnamed_addr constant {} zeroinitializer | |
; Function Attrs: inlinehint nounwind | |
define double @abs(double %n) #0 { | |
entry: | |
%fcmpugttmp = fcmp ugt double %n, 0.000000e+00 | |
br i1 %fcmpugttmp, label %if.expr.then, label %if.expr.else | |
if.expr.then: ; preds = %entry | |
br label %if.expr.end | |
if.expr.else: ; preds = %entry | |
%fnegtmp = fsub double -0.000000e+00, %n | |
br label %if.expr.end | |
if.expr.end: ; preds = %if.expr.else, %if.expr.then | |
%if.expr.phi = phi double [ %n, %if.expr.then ], [ %fnegtmp, %if.expr.else ] | |
ret double %if.expr.phi | |
} | |
; Function Attrs: inlinehint nounwind | |
define double @sqrt2(double %p, double %z, double %x) #0 { | |
entry: | |
%fsubtmp = fsub double %p, %z | |
%0 = call double @abs(double %fsubtmp) | |
%fcmpulttmp = fcmp ult double %0, 1.000000e-05 | |
br i1 %fcmpulttmp, label %postfixif.then, label %postfixif.end | |
postfixif.then: ; preds = %entry | |
ret double %z | |
postfixif.end: ; preds = %entry | |
%fmultmp = fmul double %z, %z | |
%fsubtmp1 = fsub double %fmultmp, %x | |
%fmultmp2 = fmul double 2.000000e+00, %z | |
%fdivtmp = fdiv double %fsubtmp1, %fmultmp2 | |
%fsubtmp3 = fsub double %z, %fdivtmp | |
%1 = call double @sqrt2(double %z, double %fsubtmp3, double %x) | |
ret double %1 | |
} | |
; Function Attrs: inlinehint nounwind | |
define double @sqrt(double %x) #0 { | |
entry: | |
%0 = call double @sqrt2(double 0.000000e+00, double %x, double %x) | |
ret double %0 | |
} | |
attributes #0 = { inlinehint nounwind } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment