[llvm] r340950 - [InstCombine] add tests for llvm.sin(-x); NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 29 11:11:42 PDT 2018


Author: spatel
Date: Wed Aug 29 11:11:42 2018
New Revision: 340950

URL: http://llvm.org/viewvc/llvm-project?rev=340950&view=rev
Log:
[InstCombine] add tests for llvm.sin(-x); NFC

Also add a corresponding test for llvm.cos with FMF to 
make sure that was handled correctly.

Added:
    llvm/trunk/test/Transforms/InstCombine/cos-sin-intrinsic.ll
      - copied, changed from r340949, llvm/trunk/test/Transforms/InstCombine/cos-intrinsic.ll
Removed:
    llvm/trunk/test/Transforms/InstCombine/cos-intrinsic.ll

Removed: llvm/trunk/test/Transforms/InstCombine/cos-intrinsic.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/cos-intrinsic.ll?rev=340949&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/cos-intrinsic.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/cos-intrinsic.ll (removed)
@@ -1,82 +0,0 @@
-; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt < %s -instcombine -S | FileCheck %s
-
-declare double    @llvm.cos.f64(double %Val)
-declare float     @llvm.cos.f32(float %Val)
-declare <2 x float> @llvm.cos.v2f32(<2 x float> %Val)
-
-declare float @llvm.fabs.f32(float %Val)
-declare <2 x float> @llvm.fabs.v2f32(<2 x float> %Val)
-
-define double @undef_arg() {
-; CHECK-LABEL: @undef_arg(
-; CHECK-NEXT:    ret double 0.000000e+00
-;
-  %r = call double @llvm.cos.f64(double undef)
-  ret double %r
-}
-
-define float @undef_arg2(float %d) {
-; CHECK-LABEL: @undef_arg2(
-; CHECK-NEXT:    [[COSVAL:%.*]] = call float @llvm.cos.f32(float [[D:%.*]])
-; CHECK-NEXT:    [[FSUM:%.*]] = fadd float [[COSVAL]], 0.000000e+00
-; CHECK-NEXT:    ret float [[FSUM]]
-;
-  %cosval   = call float @llvm.cos.f32(float %d)
-  %cosval2  = call float @llvm.cos.f32(float undef)
-  %fsum   = fadd float %cosval2, %cosval
-  ret float %fsum
-}
-
-define float @fneg_f32(float %x) {
-; CHECK-LABEL: @fneg_f32(
-; CHECK-NEXT:    [[COS:%.*]] = call float @llvm.cos.f32(float [[X:%.*]])
-; CHECK-NEXT:    ret float [[COS]]
-;
-  %x.fneg = fsub float -0.0, %x
-  %cos = call float @llvm.cos.f32(float %x.fneg)
-  ret float %cos
-}
-
-define <2 x float> @fneg_v2f32(<2 x float> %x) {
-; CHECK-LABEL: @fneg_v2f32(
-; CHECK-NEXT:    [[COS:%.*]] = call <2 x float> @llvm.cos.v2f32(<2 x float> [[X:%.*]])
-; CHECK-NEXT:    ret <2 x float> [[COS]]
-;
-  %x.fneg = fsub <2 x float> <float -0.0, float -0.0>, %x
-  %cos = call <2 x float> @llvm.cos.v2f32(<2 x float> %x.fneg)
-  ret <2 x float> %cos
-}
-
-define float @fabs_f32(float %x) {
-; CHECK-LABEL: @fabs_f32(
-; CHECK-NEXT:    [[COS:%.*]] = call float @llvm.cos.f32(float [[X:%.*]])
-; CHECK-NEXT:    ret float [[COS]]
-;
-  %x.fabs = call float @llvm.fabs.f32(float %x)
-  %cos = call float @llvm.cos.f32(float %x.fabs)
-  ret float %cos
-}
-
-define float @fabs_fneg_f32(float %x) {
-; CHECK-LABEL: @fabs_fneg_f32(
-; CHECK-NEXT:    [[COS:%.*]] = call float @llvm.cos.f32(float [[X:%.*]])
-; CHECK-NEXT:    ret float [[COS]]
-;
-  %x.fabs = call float @llvm.fabs.f32(float %x)
-  %x.fabs.fneg = fsub float -0.0, %x.fabs
-  %cos = call float @llvm.cos.f32(float %x.fabs.fneg)
-  ret float %cos
-}
-
-define <2 x float> @fabs_fneg_v2f32(<2 x float> %x) {
-; CHECK-LABEL: @fabs_fneg_v2f32(
-; CHECK-NEXT:    [[COS:%.*]] = call <2 x float> @llvm.cos.v2f32(<2 x float> [[X:%.*]])
-; CHECK-NEXT:    ret <2 x float> [[COS]]
-;
-  %x.fabs = call <2 x float> @llvm.fabs.v2f32(<2 x float> %x)
-  %x.fabs.fneg = fsub <2 x float> <float -0.0, float -0.0>, %x.fabs
-  %cos = call <2 x float> @llvm.cos.v2f32(<2 x float> %x.fabs.fneg)
-  ret <2 x float> %cos
-}
-

Copied: llvm/trunk/test/Transforms/InstCombine/cos-sin-intrinsic.ll (from r340949, llvm/trunk/test/Transforms/InstCombine/cos-intrinsic.ll)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/cos-sin-intrinsic.ll?p2=llvm/trunk/test/Transforms/InstCombine/cos-sin-intrinsic.ll&p1=llvm/trunk/test/Transforms/InstCombine/cos-intrinsic.ll&r1=340949&r2=340950&rev=340950&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/cos-intrinsic.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/cos-sin-intrinsic.ll Wed Aug 29 11:11:42 2018
@@ -48,6 +48,18 @@ define <2 x float> @fneg_v2f32(<2 x floa
   ret <2 x float> %cos
 }
 
+; FMF are not required, but they should propagate.
+
+define <2 x float> @fneg_cos_fmf(<2 x float> %x){
+; CHECK-LABEL: @fneg_cos_fmf(
+; CHECK-NEXT:    [[R:%.*]] = call nnan afn <2 x float> @llvm.cos.v2f32(<2 x float> [[X:%.*]])
+; CHECK-NEXT:    ret <2 x float> [[R]]
+;
+  %negx = fsub fast <2 x float> <float -0.0, float -0.0>, %x
+  %r = call nnan afn <2 x float> @llvm.cos.v2f32(<2 x float> %negx)
+  ret <2 x float> %r
+}
+
 define float @fabs_f32(float %x) {
 ; CHECK-LABEL: @fabs_f32(
 ; CHECK-NEXT:    [[COS:%.*]] = call float @llvm.cos.f32(float [[X:%.*]])
@@ -80,3 +92,31 @@ define <2 x float> @fabs_fneg_v2f32(<2 x
   ret <2 x float> %cos
 }
 
+; TODO: Negate is canonicalized after sin.
+
+declare <2 x float> @llvm.sin.v2f32(<2 x float>)
+
+define <2 x float> @fneg_sin(<2 x float> %x){
+; CHECK-LABEL: @fneg_sin(
+; CHECK-NEXT:    [[NEGX:%.*]] = fsub <2 x float> <float -0.000000e+00, float -0.000000e+00>, [[X:%.*]]
+; CHECK-NEXT:    [[R:%.*]] = call <2 x float> @llvm.sin.v2f32(<2 x float> [[NEGX]])
+; CHECK-NEXT:    ret <2 x float> [[R]]
+;
+  %negx = fsub <2 x float> <float -0.0, float -0.0>, %x
+  %r = call <2 x float> @llvm.sin.v2f32(<2 x float> %negx)
+  ret <2 x float> %r
+}
+
+; TODO: FMF are not required, but they should propagate.
+
+define <2 x float> @fneg_sin_fmf(<2 x float> %x){
+; CHECK-LABEL: @fneg_sin_fmf(
+; CHECK-NEXT:    [[NEGX:%.*]] = fsub fast <2 x float> <float -0.000000e+00, float -0.000000e+00>, [[X:%.*]]
+; CHECK-NEXT:    [[R:%.*]] = call nnan arcp afn <2 x float> @llvm.sin.v2f32(<2 x float> [[NEGX]])
+; CHECK-NEXT:    ret <2 x float> [[R]]
+;
+  %negx = fsub fast <2 x float> <float -0.0, float -0.0>, %x
+  %r = call nnan arcp afn <2 x float> @llvm.sin.v2f32(<2 x float> %negx)
+  ret <2 x float> %r
+}
+




More information about the llvm-commits mailing list