[llvm] 4e78bd3 - [InstCombine][test] add tests for FP min/max with negated op; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 22 11:16:46 PDT 2021
Author: Sanjay Patel
Date: 2021-06-22T14:15:04-04:00
New Revision: 4e78bd3836ce7352c5c5e1818e88a781498f216e
URL: https://github.com/llvm/llvm-project/commit/4e78bd3836ce7352c5c5e1818e88a781498f216e
DIFF: https://github.com/llvm/llvm-project/commit/4e78bd3836ce7352c5c5e1818e88a781498f216e.diff
LOG: [InstCombine][test] add tests for FP min/max with negated op; NFC
Added:
Modified:
llvm/test/Transforms/InstCombine/maxnum.ll
llvm/test/Transforms/InstCombine/minnum.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/maxnum.ll b/llvm/test/Transforms/InstCombine/maxnum.ll
index 71ce436c7149..f7e7a3cb9f0e 100644
--- a/llvm/test/Transforms/InstCombine/maxnum.ll
+++ b/llvm/test/Transforms/InstCombine/maxnum.ll
@@ -433,3 +433,38 @@ define float @reduce_precision_multi_use_1(float %x, float %y) {
%trunc = fptrunc double %maxnum to float
ret float %trunc
}
+
+define float @negated_op(float %x) {
+; CHECK-LABEL: @negated_op(
+; CHECK-NEXT: [[NEGX:%.*]] = fneg float [[X:%.*]]
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.maxnum.f32(float [[NEGX]], float [[X]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %negx = fneg float %x
+ %r = call float @llvm.maxnum.f32(float %negx, float %x)
+ ret float %r
+}
+
+define <2 x double> @negated_op_fmf_commute_vec(<2 x double> %x) {
+; CHECK-LABEL: @negated_op_fmf_commute_vec(
+; CHECK-NEXT: [[NEGX:%.*]] = fneg <2 x double> [[X:%.*]]
+; CHECK-NEXT: [[R:%.*]] = call nnan ninf nsz <2 x double> @llvm.maxnum.v2f64(<2 x double> [[X]], <2 x double> [[NEGX]])
+; CHECK-NEXT: ret <2 x double> [[R]]
+;
+ %negx = fneg <2 x double> %x
+ %r = call nsz nnan ninf <2 x double> @llvm.maxnum.v2f64(<2 x double> %x, <2 x double> %negx)
+ ret <2 x double> %r
+}
+
+define float @negated_op_extra_use(float %x) {
+; CHECK-LABEL: @negated_op_extra_use(
+; CHECK-NEXT: [[NEGX:%.*]] = fneg float [[X:%.*]]
+; CHECK-NEXT: call void @use(float [[NEGX]])
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.maxnum.f32(float [[NEGX]], float [[X]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %negx = fneg float %x
+ call void @use(float %negx)
+ %r = call float @llvm.maxnum.f32(float %negx, float %x)
+ ret float %r
+}
diff --git a/llvm/test/Transforms/InstCombine/minnum.ll b/llvm/test/Transforms/InstCombine/minnum.ll
index 007c4aa1a77b..ccae0957a0e3 100644
--- a/llvm/test/Transforms/InstCombine/minnum.ll
+++ b/llvm/test/Transforms/InstCombine/minnum.ll
@@ -470,3 +470,38 @@ define float @reduce_precision_multi_use_1(float %x, float %y) {
%trunc = fptrunc double %minnum to float
ret float %trunc
}
+
+define float @negated_op(float %x) {
+; CHECK-LABEL: @negated_op(
+; CHECK-NEXT: [[NEGX:%.*]] = fneg float [[X:%.*]]
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.minnum.f32(float [[X]], float [[NEGX]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %negx = fneg float %x
+ %r = call float @llvm.minnum.f32(float %x, float %negx)
+ ret float %r
+}
+
+define <2 x double> @negated_op_fmf_commute_vec(<2 x double> %x) {
+; CHECK-LABEL: @negated_op_fmf_commute_vec(
+; CHECK-NEXT: [[NEGX:%.*]] = fneg <2 x double> [[X:%.*]]
+; CHECK-NEXT: [[R:%.*]] = call nnan ninf nsz <2 x double> @llvm.minnum.v2f64(<2 x double> [[NEGX]], <2 x double> [[X]])
+; CHECK-NEXT: ret <2 x double> [[R]]
+;
+ %negx = fneg <2 x double> %x
+ %r = call nsz nnan ninf <2 x double> @llvm.minnum.v2f64(<2 x double> %negx, <2 x double> %x)
+ ret <2 x double> %r
+}
+
+define double @negated_op_extra_use(double %x) {
+; CHECK-LABEL: @negated_op_extra_use(
+; CHECK-NEXT: [[NEGX:%.*]] = fneg double [[X:%.*]]
+; CHECK-NEXT: call void @use(double [[NEGX]])
+; CHECK-NEXT: [[R:%.*]] = call double @llvm.minnum.f64(double [[NEGX]], double [[X]])
+; CHECK-NEXT: ret double [[R]]
+;
+ %negx = fneg double %x
+ call void @use(double %negx)
+ %r = call double @llvm.minnum.f64(double %negx, double %x)
+ ret double %r
+}
More information about the llvm-commits
mailing list