[llvm] [NVPTX] Constant fold NVVM fmin and fmax (PR #121966)
Artem Belevich via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 14 11:59:37 PST 2025
================
@@ -0,0 +1,614 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
+; RUN: opt < %s -passes=instsimplify -march=nvptx64 --mcpu=sm_86 --mattr=+ptx72 -S | FileCheck %s
+
+; Check constant-folding for NVVM fmin fmax intrinsics
+
+;###############################################################
+;# FMax(1.25, -2.0) #
+;###############################################################
+
+define double @test_fmax_1_25_neg_2_d() {
+; CHECK-LABEL: define double @test_fmax_1_25_neg_2_d() {
+; CHECK-NEXT: ret double 1.250000e+00
+;
+ %res = call double @llvm.nvvm.fmax.d(double 1.25, double -2.0)
+ ret double %res
+}
+
+define float @test_fmax_1_25_neg_2_f() {
+; CHECK-LABEL: define float @test_fmax_1_25_neg_2_f() {
+; CHECK-NEXT: ret float 1.250000e+00
+;
+ %res = call float @llvm.nvvm.fmax.f(float 1.25, float -2.0)
+ ret float %res
+}
+
+define float @test_fmax_1_25_neg_2_ftz_f() {
+; CHECK-LABEL: define float @test_fmax_1_25_neg_2_ftz_f() {
+; CHECK-NEXT: ret float 1.250000e+00
+;
+ %res = call float @llvm.nvvm.fmax.ftz.f(float 1.25, float -2.0)
----------------
Artem-B wrote:
Thank you.
> The inputs (1.25, -2.0) are only there to test that the intrinsics function as expected for regular (non-subnormal) floats, so the FTZ and non-FTZ variants are expected to behave identically for those inputs.
Agreed. It is useful, but it's the corner cases I would like to check. They tests you've already added cover most of the insteresting combinations, but we still seem to be missing the tests for `{normal FP, Subnormal}` combinations.
E.g. `fmax(0.0, +Subnormal)`. FTZ variant would return 0.0, while non-FTZ would presumably pass through `+Subnormal`.
https://github.com/llvm/llvm-project/pull/121966
More information about the llvm-commits
mailing list