[llvm] [NVPTX] Constant fold NVVM fmin and fmax (PR #121966)

Artem Belevich via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 10 11:39:49 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:

Let me rephrase. For the tests `@test_fmax_1_25_neg_2_f` and `@test_fmax_1_25_neg_2_ftz_f`, is there a set of the input values, that would produce different results in those two tests?

Right now the behavior of the ftz/non-ftz variants of the intrinsics in the tests is indistinguishable.
If they can behave differently, the tests should cover that. 

https://github.com/llvm/llvm-project/pull/121966


More information about the llvm-commits mailing list