[llvm] r357816 - [InstCombine] add more tests for fmul+fdiv+sqrt; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 5 13:54:35 PDT 2019
Author: spatel
Date: Fri Apr 5 13:54:35 2019
New Revision: 357816
URL: http://llvm.org/viewvc/llvm-project?rev=357816&view=rev
Log:
[InstCombine] add more tests for fmul+fdiv+sqrt; NFC
Modified:
llvm/trunk/test/Transforms/InstCombine/fmul-sqrt.ll
Modified: llvm/trunk/test/Transforms/InstCombine/fmul-sqrt.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/fmul-sqrt.ll?rev=357816&r1=357815&r2=357816&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/fmul-sqrt.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/fmul-sqrt.ll Fri Apr 5 13:54:35 2019
@@ -88,8 +88,8 @@ define double @sqrt_a_sqrt_b_sqrt_c_sqrt
ret double %mul2
}
-define double @sqrt_squared(double %x) {
-; CHECK-LABEL: @sqrt_squared(
+define double @rsqrt_squared(double %x) {
+; CHECK-LABEL: @rsqrt_squared(
; CHECK-NEXT: [[SQRT:%.*]] = call fast double @llvm.sqrt.f64(double [[X:%.*]])
; CHECK-NEXT: [[RSQRT:%.*]] = fdiv fast double 1.000000e+00, [[SQRT]]
; CHECK-NEXT: [[SQUARED:%.*]] = fmul fast double [[RSQRT]], [[RSQRT]]
@@ -101,6 +101,47 @@ define double @sqrt_squared(double %x) {
ret double %squared
}
+define double @sqrt_divisor_squared(double %x, double %y) {
+; CHECK-LABEL: @sqrt_divisor_squared(
+; CHECK-NEXT: [[SQRT:%.*]] = call double @llvm.sqrt.f64(double [[X:%.*]])
+; CHECK-NEXT: [[DIV:%.*]] = fdiv double [[Y:%.*]], [[SQRT]]
+; CHECK-NEXT: [[SQUARED:%.*]] = fmul reassoc nnan nsz double [[DIV]], [[DIV]]
+; CHECK-NEXT: ret double [[SQUARED]]
+;
+ %sqrt = call double @llvm.sqrt.f64(double %x)
+ %div = fdiv double %y, %sqrt
+ %squared = fmul reassoc nnan nsz double %div, %div
+ ret double %squared
+}
+
+define double @sqrt_dividend_squared(double %x, double %y) {
+; CHECK-LABEL: @sqrt_dividend_squared(
+; CHECK-NEXT: [[SQRT:%.*]] = call double @llvm.sqrt.f64(double [[X:%.*]])
+; CHECK-NEXT: [[DIV:%.*]] = fdiv fast double [[SQRT]], [[Y:%.*]]
+; CHECK-NEXT: [[SQUARED:%.*]] = fmul fast double [[DIV]], [[DIV]]
+; CHECK-NEXT: ret double [[SQUARED]]
+;
+ %sqrt = call double @llvm.sqrt.f64(double %x)
+ %div = fdiv fast double %sqrt, %y
+ %squared = fmul fast double %div, %div
+ ret double %squared
+}
+
+; Negative test - require 'nsz'.
+
+define double @sqrt_divisor_not_enough_FMF(double %x, double %y) {
+; CHECK-LABEL: @sqrt_divisor_not_enough_FMF(
+; CHECK-NEXT: [[SQRT:%.*]] = call double @llvm.sqrt.f64(double [[X:%.*]])
+; CHECK-NEXT: [[DIV:%.*]] = fdiv double [[Y:%.*]], [[SQRT]]
+; CHECK-NEXT: [[SQUARED:%.*]] = fmul reassoc nnan double [[DIV]], [[DIV]]
+; CHECK-NEXT: ret double [[SQUARED]]
+;
+ %sqrt = call double @llvm.sqrt.f64(double %x)
+ %div = fdiv double %y, %sqrt
+ %squared = fmul reassoc nnan double %div, %div
+ ret double %squared
+}
+
define double @sqrt_squared_extra_use(double %x) {
; CHECK-LABEL: @sqrt_squared_extra_use(
; CHECK-NEXT: [[SQRT:%.*]] = call fast double @llvm.sqrt.f64(double [[X:%.*]])
More information about the llvm-commits
mailing list