Skip to content

Add hw sqrt for x86_64#681

Merged
andrewrk merged 1 commit intomasterfrom
hw-math
Jan 10, 2018
Merged

Add hw sqrt for x86_64#681
andrewrk merged 1 commit intomasterfrom
hw-math

Conversation

@tiehuis
Copy link
Member

@tiehuis tiehuis commented Jan 10, 2018

In the process of doing the remaining i386/x86_64 instructions too. Need to work out some inline assembly issues first.

@andrewrk
Copy link
Member

hmm, if there's a hardware instruction for sqrt, maybe we should add @sqrt because there is an LLVM intrinsic that can probably lower to this sqrt instruction (and the sqrt instructions on the other architectures too): http://llvm.org/docs/LangRef.html#llvm-sqrt-intrinsic

The other problem a builtin would solve is executing std.math.sqrt at compile time. Without a builtin, we would need some kind of feature to detect whether we're executing at compile time or not. (because inline assembly cannot be executed at compile time).

We would still need the zig implementation of sqrt (with the modification proposed here) to put into builtin.o, because the sqrt llvm intrinsic can lower to a call to that function. So this is good to merge. I'll add a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants