Page MenuHomePhabricator

[CodeGen] __builtin_sqrt should map to the compiler's intrinsic sqrt function
AbandonedPublic

Authored by spatel on Oct 21 2017, 8:12 AM.

Details

Summary

This patch is intended to answer a question raised in PR27435:
https://bugs.llvm.org/show_bug.cgi?id=27435

Is a programmer using __builtin_sqrt() invoking the compiler's intrinsic definition of sqrt or the mathlib definition of sqrt?

I know there are follow-up bugs that still need to be solved (D28335), but I think we should answer this first. Also if this patch is correct, it is enough to produce the hoped-for result in the PR27435 examples because we'll get this IR at -O2:

$ ./clang -O2 27435.c -S -o - -emit-llvm | grep llvm.sqrt

%2 = call <2 x double> @llvm.sqrt.v2f64(<2 x double> %1)
%2 = call <4 x float> @llvm.sqrt.v4f32(<4 x float> %1)

Diff Detail

Event Timeline

spatel created this revision.Oct 21 2017, 8:12 AM

Oops - I wrongly made llvm-commits a subscriber rather than cfe-commits. Let me know if I should reopen under a new thread to get the patch to hit the right mailing list.

hfinkel edited edge metadata.Oct 23 2017, 1:11 PM

Oops - I wrongly made llvm-commits a subscriber rather than cfe-commits. Let me know if I should reopen under a new thread to get the patch to hit the right mailing list.

Yes, please reopen.

spatel abandoned this revision.Oct 23 2017, 1:50 PM

Reincarnated as D39204.