Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(463)

Unified Diff: tests_lit/llvm2ice_tests/nacl-other-intrinsics.ll

Issue 384443003: Add scalar lowering for sqrt intrinsic. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: whitespace Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/IceTargetLoweringX8632.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests_lit/llvm2ice_tests/nacl-other-intrinsics.ll
diff --git a/tests_lit/llvm2ice_tests/nacl-other-intrinsics.ll b/tests_lit/llvm2ice_tests/nacl-other-intrinsics.ll
index 15f9a6576d15e422cbed8b0967d1c74d6292a39c..5ed776be07272ca0d209addbcf54b9ffe3130ae0 100644
--- a/tests_lit/llvm2ice_tests/nacl-other-intrinsics.ll
+++ b/tests_lit/llvm2ice_tests/nacl-other-intrinsics.ll
@@ -15,6 +15,8 @@ declare void @llvm.memmove.p0i8.p0i8.i32(i8*, i8*, i32, i32, i1)
declare void @llvm.memset.p0i8.i32(i8*, i8, i32, i32, i1)
declare void @llvm.nacl.longjmp(i8*, i32)
declare i32 @llvm.nacl.setjmp(i8*)
+declare float @llvm.sqrt.f32(float)
+declare double @llvm.sqrt.f64(double)
declare void @llvm.trap()
define i32 @test_nacl_read_tp() {
@@ -160,6 +162,63 @@ entry:
; CHECKO2REM-LABEL: test_setjmp_unused
; CHECKO2REM: call setjmp
+define float @test_sqrt_float(float %x, i32 %iptr) {
+entry:
+ %r = call float @llvm.sqrt.f32(float %x)
+ %r2 = call float @llvm.sqrt.f32(float %r)
+ %r3 = call float @llvm.sqrt.f32(float -0.0)
+ %r4 = fadd float %r2, %r3
+ br label %next
+
+next:
+ %__6 = inttoptr i32 %iptr to float*
+ %y = load float* %__6, align 4
+ %r5 = call float @llvm.sqrt.f32(float %y)
+ %r6 = fadd float %r4, %r5
+ ret float %r6
+}
+; CHECK-LABEL: test_sqrt_float
+; CHECK: sqrtss xmm{{.*}}
+; CHECK: sqrtss xmm{{.*}}
+; CHECK: sqrtss xmm{{.*}}, dword ptr
+; CHECK-LABEL: .L{{.*}}next
+; We could fold the load and the sqrt into one operation, but the
+; current folding only handles load + arithmetic op. The sqrt inst
+; is considered an intrinsic call and not an arithmetic op.
+; CHECK: sqrtss xmm{{.*}}
+
+define double @test_sqrt_double(double %x, i32 %iptr) {
+entry:
+ %r = call double @llvm.sqrt.f64(double %x)
+ %r2 = call double @llvm.sqrt.f64(double %r)
+ %r3 = call double @llvm.sqrt.f64(double -0.0)
+ %r4 = fadd double %r2, %r3
+ br label %next
+
+next:
+ %__6 = inttoptr i32 %iptr to double*
+ %y = load double* %__6, align 8
+ %r5 = call double @llvm.sqrt.f64(double %y)
+ %r6 = fadd double %r4, %r5
+ ret double %r6
+}
+; CHECK-LABEL: test_sqrt_double
+; CHECK: sqrtsd xmm{{.*}}
+; CHECK: sqrtsd xmm{{.*}}
+; CHECK: sqrtsd xmm{{.*}}, qword ptr
+; CHECK-LABEL: .L{{.*}}next
+; CHECK: sqrtsd xmm{{.*}}
+
+define float @test_sqrt_ignored(float %x, double %y) {
+entry:
+ %ignored1 = call float @llvm.sqrt.f32(float %x)
+ %ignored2 = call double @llvm.sqrt.f64(double %y)
+ ret float 0.0
+}
+; CHECKO2REM-LABEL: test_sqrt_ignored
+; CHECKO2REM-NOT: sqrtss
+; CHECKO2REM-NOT: sqrtsd
+
define i32 @test_trap(i32 %br) {
entry:
%r1 = icmp eq i32 %br, 0
« no previous file with comments | « src/IceTargetLoweringX8632.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698