[llvm] 19293b8 - Inline: Fix case of not inlining with denormal-fp-math-f32

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 9 16:09:55 PDT 2023


Author: Matt Arsenault
Date: 2023-06-09T19:09:48-04:00
New Revision: 19293b82c180660de9636ebe8caa01fe797fb388

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

LOG: Inline: Fix case of not inlining with denormal-fp-math-f32

This was failing to inline the opencl libraries with daz enabled. As a
modifier to the base mode, denormal-fp-mode-f32 is weird and has no
meaning if it's missing.

Added: 
    

Modified: 
    llvm/lib/IR/Attributes.cpp
    llvm/test/Transforms/Inline/AMDGPU/inline-denormal-fp-math.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp
index c1c4c0fc81a52..ace23f339ab79 100644
--- a/llvm/lib/IR/Attributes.cpp
+++ b/llvm/lib/IR/Attributes.cpp
@@ -2026,6 +2026,10 @@ static bool checkDenormMode(const Function &Caller, const Function &Callee) {
   if (denormModeCompatible(CallerMode, CalleeMode)) {
     DenormalMode CallerModeF32 = Caller.getDenormalModeF32Raw();
     DenormalMode CalleeModeF32 = Callee.getDenormalModeF32Raw();
+    if (CallerModeF32 == DenormalMode::getInvalid())
+      CallerModeF32 = CallerMode;
+    if (CalleeModeF32 == DenormalMode::getInvalid())
+      CalleeModeF32 = CalleeMode;
     return denormModeCompatible(CallerModeF32, CalleeModeF32);
   }
 

diff  --git a/llvm/test/Transforms/Inline/AMDGPU/inline-denormal-fp-math.ll b/llvm/test/Transforms/Inline/AMDGPU/inline-denormal-fp-math.ll
index a7e83ece6d604..e58f09e5edc34 100644
--- a/llvm/test/Transforms/Inline/AMDGPU/inline-denormal-fp-math.ll
+++ b/llvm/test/Transforms/Inline/AMDGPU/inline-denormal-fp-math.ll
@@ -829,8 +829,7 @@ define i32 @call_psz_psz_from_ieee_ieee_f32() #11 {
 
 define i32 @call_dynamic_dynamic_from_psz_psz_f32() #10 {
 ; CHECK-LABEL: @call_dynamic_dynamic_from_psz_psz_f32(
-; CHECK-NEXT:    [[RESULT:%.*]] = call i32 @func_dynamic_dynamic()
-; CHECK-NEXT:    ret i32 [[RESULT]]
+; CHECK-NEXT:    ret i32 5
 ;
   %result = call i32 @func_dynamic_dynamic()
   ret i32 %result
@@ -856,8 +855,7 @@ define i32 @call_psz_psz_f32_from_psz_psz() #1 {
 
 define i32 @call_dynamic_dynamic_psz_psz_f32_from_psz_psz() #1 {
 ; CHECK-LABEL: @call_dynamic_dynamic_psz_psz_f32_from_psz_psz(
-; CHECK-NEXT:    [[RESULT:%.*]] = call i32 @func_dynamic_dynamic_psz_psz_f32()
-; CHECK-NEXT:    ret i32 [[RESULT]]
+; CHECK-NEXT:    ret i32 12
 ;
   %result = call i32 @func_dynamic_dynamic_psz_psz_f32()
   ret i32 %result


        


More information about the llvm-commits mailing list