[llvm] f81f47e - [InstCombine] Add fptrunc of max test (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 25 01:56:31 PST 2024


Author: Nikita Popov
Date: 2024-11-25T10:56:24+01:00
New Revision: f81f47e3ff29598fdf58cde94ccf2c7d4be53df5

URL: https://github.com/llvm/llvm-project/commit/f81f47e3ff29598fdf58cde94ccf2c7d4be53df5
DIFF: https://github.com/llvm/llvm-project/commit/f81f47e3ff29598fdf58cde94ccf2c7d4be53df5.diff

LOG: [InstCombine] Add fptrunc of max test (NFC)

To guard against regression from #117182.

Added: 
    

Modified: 
    llvm/test/Transforms/InstCombine/fptrunc.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/fptrunc.ll b/llvm/test/Transforms/InstCombine/fptrunc.ll
index f46940ff060d41..a4296a326c4bc6 100644
--- a/llvm/test/Transforms/InstCombine/fptrunc.ll
+++ b/llvm/test/Transforms/InstCombine/fptrunc.ll
@@ -90,6 +90,19 @@ define half @fptrunc_select_true_val_extra_use(half %x, float %y, i1 %cond) {
   ret half %r
 }
 
+define half @fptrunc_max(half %arg) {
+; CHECK-LABEL: @fptrunc_max(
+; CHECK-NEXT:    [[CMP:%.*]] = fcmp olt half [[ARG:%.*]], 0xH0000
+; CHECK-NEXT:    [[NARROW_SEL:%.*]] = select i1 [[CMP]], half 0xH0000, half [[ARG]]
+; CHECK-NEXT:    ret half [[NARROW_SEL]]
+;
+  %ext = fpext half %arg to double
+  %cmp = fcmp olt double %ext, 0.000000e+00
+  %max = select i1 %cmp, double 0.000000e+00, double %ext
+  %trunc = fptrunc double %max to half
+  ret half %trunc
+}
+
 ; Negative test - this would require an extra instruction.
 
 define half @fptrunc_select_true_val_extra_use_2(half %x, float %y, i1 %cond) {


        


More information about the llvm-commits mailing list