From 145c90b4683c0fa2afdfd57191275e814101605b Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Mon, 26 Oct 2015 23:52:42 +0000 Subject: [PATCH] add FP logic test cases to show current codegen (PR22428) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251370 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/CodeGen/X86/fp-logic.ll | 60 ++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/test/CodeGen/X86/fp-logic.ll b/test/CodeGen/X86/fp-logic.ll index e45e48dfa98..6494d4967c3 100644 --- a/test/CodeGen/X86/fp-logic.ll +++ b/test/CodeGen/X86/fp-logic.ll @@ -193,6 +193,34 @@ define float @xor(float %x, float %y) { ret float %bc3 } +define float @f7_or(float %x) { +; CHECK-LABEL: f7_or: +; CHECK: # BB#0: +; CHECK-NEXT: movd %xmm0, %eax +; CHECK-NEXT: orl $3, %eax +; CHECK-NEXT: movd %eax, %xmm0 +; CHECK-NEXT: retq + + %bc1 = bitcast float %x to i32 + %and = or i32 %bc1, 3 + %bc2 = bitcast i32 %and to float + ret float %bc2 +} + +define float @f7_xor(float %x) { +; CHECK-LABEL: f7_xor: +; CHECK: # BB#0: +; CHECK-NEXT: movd %xmm0, %eax +; CHECK-NEXT: xorl $3, %eax +; CHECK-NEXT: movd %eax, %xmm0 +; CHECK-NEXT: retq + + %bc1 = bitcast float %x to i32 + %and = xor i32 %bc1, 3 + %bc2 = bitcast i32 %and to float + ret float %bc2 +} + ; Make sure that doubles work too. define double @doubles(double %x, double %y) { @@ -208,3 +236,35 @@ define double @doubles(double %x, double %y) { ret double %bc3 } +define double @f7_double(double %x) { +; CHECK-LABEL: f7_double: +; CHECK: # BB#0: +; CHECK-NEXT: movd %xmm0, %rax +; CHECK-NEXT: andl $3, %eax +; CHECK-NEXT: movd %rax, %xmm0 +; CHECK-NEXT: retq + + %bc1 = bitcast double %x to i64 + %and = and i64 %bc1, 3 + %bc2 = bitcast i64 %and to double + ret double %bc2 +} + +; Grabbing the sign bit is a special case that could be handled +; by movmskps/movmskpd, but if we're not shifting it over, then +; a simple FP logic op is cheaper. + +define float @movmsk(float %x) { +; CHECK-LABEL: movmsk: +; CHECK: # BB#0: +; CHECK-NEXT: movmskps %xmm0, %eax +; CHECK-NEXT: shll $31, %eax +; CHECK-NEXT: movd %eax, %xmm0 +; CHECK-NEXT: retq + + %bc1 = bitcast float %x to i32 + %and = and i32 %bc1, 2147483648 + %bc2 = bitcast i32 %and to float + ret float %bc2 +} + -- 2.34.1