llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-transforms

Author: Matt Arsenault (arsenm)

<details>
<summary>Changes</summary>

Use the new common utility function to try fold to constant
or introduce flags.

---
Full diff: https://github.com/llvm/llvm-project/pull/177767.diff


3 Files Affected:

- (modified) llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp 
(+1-2) 
- (modified) llvm/test/Transforms/InstCombine/simplify-demanded-fpclass-log.ll 
(+8-8) 
- (modified) llvm/test/Transforms/InstCombine/simplify-demanded-fpclass.ll 
(+2-2) 


``````````diff
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp 
b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
index 2c6b585a13251..fa56c7cd68e2b 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
@@ -2958,8 +2958,7 @@ Value 
*InstCombinerImpl::SimplifyDemandedUseFPClass(Instruction *I,
       Known = KnownFPClass::log(KnownSrc, Mode);
       Known.knownNot(~DemandedMask);
 
-      return getFPClassConstant(VTy, Known.KnownFPClasses,
-                                /*IsCanonicalizing=*/true);
+      return simplifyDemandedFPClassResult(CI, FMF, DemandedMask, Known, 
KnownSrc);
     }
     case Intrinsic::sqrt: {
       FPClassTest DemandedSrcMask =
diff --git a/llvm/test/Transforms/InstCombine/simplify-demanded-fpclass-log.ll 
b/llvm/test/Transforms/InstCombine/simplify-demanded-fpclass-log.ll
index 455d37019c965..5bbda74c4f3c2 100644
--- a/llvm/test/Transforms/InstCombine/simplify-demanded-fpclass-log.ll
+++ b/llvm/test/Transforms/InstCombine/simplify-demanded-fpclass-log.ll
@@ -64,7 +64,7 @@ define nofpclass(nan inf norm sub pzero) float 
@ret_nofpclass_only_nzero__log(fl
 define nofpclass(nan norm sub zero) float @ret_nofpclass_only_inf__log(float 
%unknown) {
 ; CHECK-LABEL: define nofpclass(nan zero sub norm) float 
@ret_nofpclass_only_inf__log(
 ; CHECK-SAME: float [[UNKNOWN:%.*]]) {
-; CHECK-NEXT:    [[RESULT:%.*]] = call float @llvm.log.f32(float [[UNKNOWN]])
+; CHECK-NEXT:    [[RESULT:%.*]] = call nnan float @llvm.log.f32(float 
[[UNKNOWN]])
 ; CHECK-NEXT:    ret float [[RESULT]]
 ;
   %result = call float @llvm.log.f32(float %unknown)
@@ -159,7 +159,7 @@ define nofpclass(ninf norm zero) float 
@ret_nofpclass_nan_or_sub__log_select__fi
 define nofpclass(pinf nan norm zero) float 
@ret_ninf_or_sub__log_select__pinf_or_sub_orzero__else_not0__ieee(i1 %cond, 
float nofpclass(ninf norm nan) %must.be.pinf.or.sub.or.zero, float 
nofpclass(zero) %not.zero) {
 ; CHECK-LABEL: define nofpclass(nan pinf zero norm) float 
@ret_ninf_or_sub__log_select__pinf_or_sub_orzero__else_not0__ieee(
 ; CHECK-SAME: i1 [[COND:%.*]], float nofpclass(nan ninf norm) 
[[MUST_BE_PINF_OR_SUB_OR_ZERO:%.*]], float nofpclass(zero) [[NOT_ZERO:%.*]]) {
-; CHECK-NEXT:    [[RESULT:%.*]] = call float @llvm.log.f32(float 
[[MUST_BE_PINF_OR_SUB_OR_ZERO]])
+; CHECK-NEXT:    [[RESULT:%.*]] = call nnan float @llvm.log.f32(float 
[[MUST_BE_PINF_OR_SUB_OR_ZERO]])
 ; CHECK-NEXT:    ret float [[RESULT]]
 ;
   %select = select i1 %cond, float %must.be.pinf.or.sub.or.zero, float 
%not.zero
@@ -172,7 +172,7 @@ define nofpclass(pinf nan norm zero) float 
@ret_ninf_or_sub__log_select__pinf_or
 ; CHECK-LABEL: define nofpclass(nan pinf zero norm) float 
@ret_ninf_or_sub__log_select__pinf_or_sub_orzero__else_not0__daz(
 ; CHECK-SAME: i1 [[COND:%.*]], float nofpclass(nan ninf norm) 
[[MUST_BE_PINF_OR_SUB_OR_ZERO:%.*]], float nofpclass(zero) [[NOT_ZERO:%.*]]) 
#[[ATTR0:[0-9]+]] {
 ; CHECK-NEXT:    [[SELECT:%.*]] = select i1 [[COND]], float 
[[MUST_BE_PINF_OR_SUB_OR_ZERO]], float [[NOT_ZERO]]
-; CHECK-NEXT:    [[RESULT:%.*]] = call float @llvm.log.f32(float [[SELECT]])
+; CHECK-NEXT:    [[RESULT:%.*]] = call nnan float @llvm.log.f32(float 
[[SELECT]])
 ; CHECK-NEXT:    ret float [[RESULT]]
 ;
   %select = select i1 %cond, float %must.be.pinf.or.sub.or.zero, float 
%not.zero
@@ -185,7 +185,7 @@ define nofpclass(pinf nan norm zero) float 
@ret_ninf_or_sub__log_select__pinf_or
 ; CHECK-LABEL: define nofpclass(nan pinf zero norm) float 
@ret_ninf_or_sub__log_select__pinf_or_sub_orzero__else_not0__dynamic(
 ; CHECK-SAME: i1 [[COND:%.*]], float nofpclass(nan ninf norm) 
[[MUST_BE_PINF_OR_SUB_OR_ZERO:%.*]], float nofpclass(zero) [[NOT_ZERO:%.*]]) 
#[[ATTR1:[0-9]+]] {
 ; CHECK-NEXT:    [[SELECT:%.*]] = select i1 [[COND]], float 
[[MUST_BE_PINF_OR_SUB_OR_ZERO]], float [[NOT_ZERO]]
-; CHECK-NEXT:    [[RESULT:%.*]] = call float @llvm.log.f32(float [[SELECT]])
+; CHECK-NEXT:    [[RESULT:%.*]] = call nnan float @llvm.log.f32(float 
[[SELECT]])
 ; CHECK-NEXT:    ret float [[RESULT]]
 ;
   %select = select i1 %cond, float %must.be.pinf.or.sub.or.zero, float 
%not.zero
@@ -197,7 +197,7 @@ define nofpclass(pinf nan norm zero) float 
@ret_ninf_or_sub__log_select__pinf_or
 define nofpclass(inf nan pnorm sub zero) float 
@ret_only_nnorm__log__select_unknown_or_infnan(i1 %cond, float %unknown, float 
nofpclass(norm sub zero) %b) {
 ; CHECK-LABEL: define nofpclass(nan inf zero sub pnorm) float 
@ret_only_nnorm__log__select_unknown_or_infnan(
 ; CHECK-SAME: i1 [[COND:%.*]], float [[UNKNOWN:%.*]], float nofpclass(zero sub 
norm) [[B:%.*]]) {
-; CHECK-NEXT:    [[RESULT:%.*]] = call float @llvm.log.f32(float [[UNKNOWN]])
+; CHECK-NEXT:    [[RESULT:%.*]] = call nnan ninf float @llvm.log.f32(float 
[[UNKNOWN]])
 ; CHECK-NEXT:    ret float [[RESULT]]
 ;
   %select = select i1 %cond, float %unknown, float %b
@@ -209,7 +209,7 @@ define nofpclass(inf nan pnorm sub zero) float 
@ret_only_nnorm__log__select_unkn
 define nofpclass(inf nan nnorm sub zero) float 
@ret_only_pnorm__log__select_unknown_or_infnan(i1 %cond, float %unknown, float 
nofpclass(norm sub zero) %b) {
 ; CHECK-LABEL: define nofpclass(nan inf zero sub nnorm) float 
@ret_only_pnorm__log__select_unknown_or_infnan(
 ; CHECK-SAME: i1 [[COND:%.*]], float [[UNKNOWN:%.*]], float nofpclass(zero sub 
norm) [[B:%.*]]) {
-; CHECK-NEXT:    [[RESULT:%.*]] = call float @llvm.log.f32(float [[UNKNOWN]])
+; CHECK-NEXT:    [[RESULT:%.*]] = call nnan ninf float @llvm.log.f32(float 
[[UNKNOWN]])
 ; CHECK-NEXT:    ret float [[RESULT]]
 ;
   %select = select i1 %cond, float %unknown, float %b
@@ -222,7 +222,7 @@ define nofpclass(nan inf norm) float 
@ret_only_zero_sub__log__select_pnormnan_or
 ; CHECK-LABEL: define nofpclass(nan inf norm) float 
@ret_only_zero_sub__log__select_pnormnan_or_unknown(
 ; CHECK-SAME: i1 [[COND:%.*]], float nofpclass(inf zero sub nnorm) 
[[PNORM_OR_NAN:%.*]], float [[B:%.*]]) {
 ; CHECK-NEXT:    [[SELECT:%.*]] = select i1 [[COND]], float [[PNORM_OR_NAN]], 
float [[B]]
-; CHECK-NEXT:    [[RESULT:%.*]] = call float @llvm.log.f32(float [[SELECT]])
+; CHECK-NEXT:    [[RESULT:%.*]] = call nnan ninf float @llvm.log.f32(float 
[[SELECT]])
 ; CHECK-NEXT:    ret float [[RESULT]]
 ;
   %select = select i1 %cond, float %pnorm.or.nan, float %b
@@ -234,7 +234,7 @@ define nofpclass(nan inf norm) float 
@ret_only_zero_sub__log__select_pnormnan_or
 define nofpclass(nan inf norm) float 
@ret_only_zero_sub__log__select_nnormnan_or_unknown(i1 %cond, float 
nofpclass(inf sub zero pnorm) %nnorm.or.nan, float %b) {
 ; CHECK-LABEL: define nofpclass(nan inf norm) float 
@ret_only_zero_sub__log__select_nnormnan_or_unknown(
 ; CHECK-SAME: i1 [[COND:%.*]], float nofpclass(inf zero sub pnorm) 
[[NNORM_OR_NAN:%.*]], float [[B:%.*]]) {
-; CHECK-NEXT:    [[RESULT:%.*]] = call float @llvm.log.f32(float [[B]])
+; CHECK-NEXT:    [[RESULT:%.*]] = call nnan ninf float @llvm.log.f32(float 
[[B]])
 ; CHECK-NEXT:    ret float [[RESULT]]
 ;
   %select = select i1 %cond, float %nnorm.or.nan, float %b
diff --git a/llvm/test/Transforms/InstCombine/simplify-demanded-fpclass.ll 
b/llvm/test/Transforms/InstCombine/simplify-demanded-fpclass.ll
index 7164d251ce0b7..bf602c4ec639d 100644
--- a/llvm/test/Transforms/InstCombine/simplify-demanded-fpclass.ll
+++ b/llvm/test/Transforms/InstCombine/simplify-demanded-fpclass.ll
@@ -1230,7 +1230,7 @@ define nofpclass(nan inf nzero nsub nnorm) float 
@powr_issue64870(float nofpclas
 ; CHECK-SAME: (float nofpclass(nan inf) [[X:%.*]], float nofpclass(nan inf) 
[[Y:%.*]]) {
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    [[I:%.*]] = tail call float @llvm.fabs.f32(float [[X]])
-; CHECK-NEXT:    [[I1:%.*]] = tail call float @llvm.log2.f32(float [[I]])
+; CHECK-NEXT:    [[I1:%.*]] = tail call nnan float @llvm.log2.f32(float [[I]])
 ; CHECK-NEXT:    [[I2:%.*]] = fmul nnan float [[I1]], [[Y]]
 ; CHECK-NEXT:    [[I3:%.*]] = tail call nnan nofpclass(ninf nzero nsub nnorm) 
float @llvm.exp2.f32(float [[I2]])
 ; CHECK-NEXT:    [[I6:%.*]] = fcmp oeq float [[X]], 0.000000e+00
@@ -1265,7 +1265,7 @@ define nofpclass(nan inf nzero nsub nnorm) float 
@test_powr_issue64870_2(float n
 ; CHECK-LABEL: define nofpclass(nan inf nzero nsub nnorm) float 
@test_powr_issue64870_2
 ; CHECK-SAME: (float nofpclass(nan inf) [[ARG:%.*]], float nofpclass(nan inf) 
[[ARG1:%.*]]) {
 ; CHECK-NEXT:  bb:
-; CHECK-NEXT:    [[I3:%.*]] = tail call float @llvm.log2.f32(float noundef 
[[ARG]])
+; CHECK-NEXT:    [[I3:%.*]] = tail call nnan float @llvm.log2.f32(float 
[[ARG]])
 ; CHECK-NEXT:    [[I5:%.*]] = fmul nnan float [[ARG1]], [[I3]]
 ; CHECK-NEXT:    [[I6:%.*]] = tail call nnan nofpclass(ninf nzero nsub nnorm) 
float @llvm.exp2.f32(float [[I5]])
 ; CHECK-NEXT:    [[TMP0:%.*]] = fcmp oeq float [[ARG]], 0.000000e+00

``````````

</details>


https://github.com/llvm/llvm-project/pull/177767
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to