[PATCH][CodeGen] Add missing intrinsic lowering for sin, cos and ceil
Josh Klontz
josh.klontz at gmail.com
Mon Aug 4 14:38:57 PDT 2014
Duncan,
Attached is an updated patch with a test case. Note, this required
extending lit to recognize `LLVM_ENABLE_FFI`.
v/r,
Josh
On Mon, Aug 4, 2014 at 2:02 PM, Duncan P. N. Exon Smith <
dexonsmith at apple.com> wrote:
> Testcase?
>
> > On 2014-Jul-30, at 05:00, Josh Klontz <josh.klontz at gmail.com> wrote:
> >
> > Ping. CC'ing code owner and release manager.
> > -Josh
> >
> >
> > On Wed, Jul 23, 2014 at 12:01 PM, Josh Klontz <josh.klontz at gmail.com>
> wrote:
> > This was discovered when trying to run lli on a function with an
> llvm.cos.f32 intrinsic. Hopefully this can get applied to the 3.5 branch as
> well. Thanks!
> > -Josh
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140804/a045b008/attachment.html>
-------------- next part --------------
diff --git a/lib/CodeGen/IntrinsicLowering.cpp b/lib/CodeGen/IntrinsicLowering.cpp
index a8b8600..9482aa6 100644
--- a/lib/CodeGen/IntrinsicLowering.cpp
+++ b/lib/CodeGen/IntrinsicLowering.cpp
@@ -527,6 +527,19 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
ReplaceFPIntrinsicWithCall(CI, "powf", "pow", "powl");
break;
}
+ case Intrinsic::sin: {
+ ReplaceFPIntrinsicWithCall(CI, "sinf", "sin", "sinl");
+ break;
+ }
+ case Intrinsic::cos: {
+ ReplaceFPIntrinsicWithCall(CI, "cosf", "cos", "cosl");
+ break;
+ }
+ case Intrinsic::ceil: {
+ ReplaceFPIntrinsicWithCall(CI, "ceilf", "ceil", "ceill");
+ break;
+ }
+
case Intrinsic::flt_rounds:
// Lower to "round to the nearest"
if (!CI->getType()->isVoidTy())
diff --git a/test/lit.site.cfg.in b/test/lit.site.cfg.in
index 4c0bb2e..8a9582a 100644
--- a/test/lit.site.cfg.in
+++ b/test/lit.site.cfg.in
@@ -22,6 +22,7 @@ config.host_arch = "@HOST_ARCH@"
config.llvm_use_intel_jitevents = "@LLVM_USE_INTEL_JITEVENTS@"
config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
config.have_zlib = "@HAVE_LIBZ@"
+config.enable_ffi = "@LLVM_ENABLE_FFI@"
# Support substitution of the tools_dir with user parameters. This is
# used when we can't determine the tool dir at configuration time.
diff --git a/test/ExecutionEngine/Interpreter/intrinsics.ll b/test/ExecutionEngine/Interpreter/intrinsics.ll
new file mode 100644
index 0000000..e827b2c
--- /dev/null
+++ b/test/ExecutionEngine/Interpreter/intrinsics.ll
@@ -0,0 +1,12 @@
+; RUN: lli -O0 -force-interpreter < %s
+
+declare float @llvm.cos.f32(float)
+declare float @llvm.sin.f32(float)
+declare float @llvm.ceil.f32(float)
+
+define i32 @main() {
+ %cos = call float @llvm.cos.f32(float 0.000000e+00)
+ %sin = call float @llvm.sin.f32(float 1.000000e+00)
+ %ceil = call float @llvm.ceil.f32(float 0.500000e+00)
+ ret i32 0
+}
\ No newline at end of file
diff --git a/test/ExecutionEngine/Interpreter/lit.local.cfg b/test/ExecutionEngine/Interpreter/lit.local.cfg
new file mode 100644
index 0000000..8cbaf03
--- /dev/null
+++ b/test/ExecutionEngine/Interpreter/lit.local.cfg
@@ -0,0 +1,3 @@
+# These tests require foreign function calls
+if config.enable_ffi != "ON":
+ config.unsupported = True
More information about the llvm-commits
mailing list