[llvm] r339579 - [InstCombine] auto-generate full checks and add cos intrinsic test; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 13 09:29:02 PDT 2018


Author: spatel
Date: Mon Aug 13 09:29:01 2018
New Revision: 339579

URL: http://llvm.org/viewvc/llvm-project?rev=339579&view=rev
Log:
[InstCombine] auto-generate full checks and add cos intrinsic test; NFC

Modified:
    llvm/trunk/test/Transforms/InstCombine/cos-1.ll

Modified: llvm/trunk/test/Transforms/InstCombine/cos-1.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/cos-1.ll?rev=339579&r1=339578&r2=339579&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/cos-1.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/cos-1.ll Mon Aug 13 09:29:01 2018
@@ -1,38 +1,55 @@
-; Test that the cos library call simplifier works correctly.
-;
-; RUN: opt < %s -instcombine -S | FileCheck %s -check-prefix=NO-FLOAT-SHRINK
-; RUN: opt < %s -instcombine -enable-double-float-shrink -S | FileCheck %s -check-prefix=DO-FLOAT-SHRINK
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -instcombine -S                             | FileCheck %s --check-prefixes=ANY,NO-FLOAT-SHRINK
+; RUN: opt < %s -instcombine -enable-double-float-shrink -S | FileCheck %s --check-prefixes=ANY,DO-FLOAT-SHRINK
 
 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
 
 declare double @cos(double)
+declare double @llvm.cos.f64(double)
 
 ; Check cos(-x) -> cos(x);
 
-define double @test_simplify1(double %d) {
-; NO-FLOAT-SHRINK-LABEL: @test_simplify1(
-  %neg = fsub double -0.000000e+00, %d
+define double @negated_arg(double %d) {
+; ANY-LABEL: @negated_arg(
+; ANY-NEXT:    [[COS1:%.*]] = call double @cos(double [[D:%.*]])
+; ANY-NEXT:    ret double [[COS1]]
+;
+  %neg = fsub double -0.0, %d
   %cos = call double @cos(double %neg)
-; NO-FLOAT-SHRINK: call double @cos(double %d)
   ret double %cos
 }
 
-define float @test_simplify2(float %f) {
-; DO-FLOAT-SHRINK-LABEL: @test_simplify2(
+define float @negated_and_shrinkable_libcall(float %f) {
+; NO-FLOAT-SHRINK-LABEL: @negated_and_shrinkable_libcall(
+; NO-FLOAT-SHRINK-NEXT:    [[CONV1:%.*]] = fpext float [[F:%.*]] to double
+; NO-FLOAT-SHRINK-NEXT:    [[COS1:%.*]] = call double @cos(double [[CONV1]])
+; NO-FLOAT-SHRINK-NEXT:    [[CONV2:%.*]] = fptrunc double [[COS1]] to float
+; NO-FLOAT-SHRINK-NEXT:    ret float [[CONV2]]
+;
+; DO-FLOAT-SHRINK-LABEL: @negated_and_shrinkable_libcall(
+; DO-FLOAT-SHRINK-NEXT:    [[COSF:%.*]] = call float @cosf(float [[F:%.*]])
+; DO-FLOAT-SHRINK-NEXT:    ret float [[COSF]]
+;
   %conv1 = fpext float %f to double
-  %neg = fsub double -0.000000e+00, %conv1
+  %neg = fsub double -0.0, %conv1
   %cos = call double @cos(double %neg)
   %conv2 = fptrunc double %cos to float
-; DO-FLOAT-SHRINK: call float @cosf(float %f)
   ret float %conv2
 }
 
-define float @test_simplify3(float %f) {
-; NO-FLOAT-SHRINK-LABEL: @test_simplify3(
+; TODO: It was ok to shrink the libcall, so the intrinsic should shrink too?
+
+define float @negated_and_shrinkable_intrinsic(float %f) {
+; ANY-LABEL: @negated_and_shrinkable_intrinsic(
+; ANY-NEXT:    [[CONV1:%.*]] = fpext float [[F:%.*]] to double
+; ANY-NEXT:    [[COS:%.*]] = call double @llvm.cos.f64(double [[CONV1]])
+; ANY-NEXT:    [[CONV2:%.*]] = fptrunc double [[COS]] to float
+; ANY-NEXT:    ret float [[CONV2]]
+;
   %conv1 = fpext float %f to double
-  %neg = fsub double -0.000000e+00, %conv1
-  %cos = call double @cos(double %neg)
-; NO-FLOAT-SHRINK: call double @cos(double %conv1)
+  %neg = fsub double -0.0, %conv1
+  %cos = call double @llvm.cos.f64(double %neg)
   %conv2 = fptrunc double %cos to float
   ret float %conv2
 }
+




More information about the llvm-commits mailing list