[llvm] 952fe94 - ConstantFolding: Fix canonicalize folding for dynamic mode denormal inputs
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 22 05:07:55 PDT 2023
Author: Matt Arsenault
Date: 2023-07-22T08:07:49-04:00
New Revision: 952fe94c72fbce1fe22265cf672e0bf41603aefc
URL: https://github.com/llvm/llvm-project/commit/952fe94c72fbce1fe22265cf672e0bf41603aefc
DIFF: https://github.com/llvm/llvm-project/commit/952fe94c72fbce1fe22265cf672e0bf41603aefc.diff
LOG: ConstantFolding: Fix canonicalize folding for dynamic mode denormal inputs
We have to assume the input could be positive-zero. Makes alive2
happy.
Added:
Modified:
llvm/lib/Analysis/ConstantFolding.cpp
llvm/test/Transforms/InstSimplify/canonicalize.ll
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index facd9721372711..08c60b42ae79c1 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -1976,7 +1976,7 @@ static Constant *constantFoldCanonicalize(const Type *Ty, const CallBase *CI,
if (DenormMode == DenormalMode::getIEEE())
return nullptr;
- if (DenormMode == DenormalMode::getDynamic())
+ if (DenormMode.Input == DenormalMode::Dynamic)
return nullptr;
// If we know if either input or output is flushed, we can fold.
diff --git a/llvm/test/Transforms/InstSimplify/canonicalize.ll b/llvm/test/Transforms/InstSimplify/canonicalize.ll
index 96b23acdf1c732..e002f101fa6d89 100644
--- a/llvm/test/Transforms/InstSimplify/canonicalize.ll
+++ b/llvm/test/Transforms/InstSimplify/canonicalize.ll
@@ -225,7 +225,8 @@ define float @canonicalize_neg_denorm_dynamic_output_preserve_sign_input() "deno
; Output is known flushed, can fold
define float @canonicalize_pos_preserve_sign_output_denorm_dynamic_input() "denormal-fp-math"="preserve-sign,dynamic" {
; CHECK-LABEL: @canonicalize_pos_preserve_sign_output_denorm_dynamic_input(
-; CHECK-NEXT: ret float 0.000000e+00
+; CHECK-NEXT: [[RET:%.*]] = call float @llvm.canonicalize.f32(float 0x380FFFFFC0000000)
+; CHECK-NEXT: ret float [[RET]]
;
%ret = call float @llvm.canonicalize.f32(float bitcast (i32 8388607 to float))
ret float %ret
@@ -234,7 +235,8 @@ define float @canonicalize_pos_preserve_sign_output_denorm_dynamic_input() "deno
; Output is known flushed, can fold
define float @canonicalize_neg_denorm_preserve_sign_output_dynamic_input() "denormal-fp-math"="preserve-sign,dynamic" {
; CHECK-LABEL: @canonicalize_neg_denorm_preserve_sign_output_dynamic_input(
-; CHECK-NEXT: ret float -0.000000e+00
+; CHECK-NEXT: [[RET:%.*]] = call float @llvm.canonicalize.f32(float 0xB80FFFFFC0000000)
+; CHECK-NEXT: ret float [[RET]]
;
%ret = call float @llvm.canonicalize.f32(float bitcast (i32 -2139095041 to float))
ret float %ret
More information about the llvm-commits
mailing list