[llvm] 8076b89 - ValueTracking: Handle fcmp true/false in fcmpToClassTest
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 22 21:11:16 PST 2024
Author: Matt Arsenault
Date: 2024-01-23T12:10:45+07:00
New Revision: 8076b896955e91cc2d16283cf8206f3354702022
URL: https://github.com/llvm/llvm-project/commit/8076b896955e91cc2d16283cf8206f3354702022
DIFF: https://github.com/llvm/llvm-project/commit/8076b896955e91cc2d16283cf8206f3354702022.diff
LOG: ValueTracking: Handle fcmp true/false in fcmpToClassTest
This ensures full compare coverage for certain special constants.
Added:
Modified:
llvm/lib/Analysis/ValueTracking.cpp
llvm/test/Transforms/Attributor/nofpclass-implied-by-fcmp.ll
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 940ae9eb7ee29a0..34d501032098888 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -4019,6 +4019,12 @@ llvm::fcmpToClassTest(FCmpInst::Predicate Pred, const Function &F, Value *LHS,
if (Pred == FCmpInst::FCMP_UNO && !ConstRHS->isNaN())
return {LHS, fcNan};
+ if (Pred == FCmpInst::FCMP_TRUE)
+ return {LHS, fcAllFlags};
+
+ if (Pred == FCmpInst::FCMP_FALSE)
+ return {LHS, fcNone};
+
if (ConstRHS->isZero()) {
// Compares with fcNone are only exactly equal to fcZero if input denormals
// are not flushed.
diff --git a/llvm/test/Transforms/Attributor/nofpclass-implied-by-fcmp.ll b/llvm/test/Transforms/Attributor/nofpclass-implied-by-fcmp.ll
index 3984dd9a25c8e0b..ccd01de458c3c4d 100644
--- a/llvm/test/Transforms/Attributor/nofpclass-implied-by-fcmp.ll
+++ b/llvm/test/Transforms/Attributor/nofpclass-implied-by-fcmp.ll
@@ -2528,8 +2528,8 @@ define float @assume_fabs_false_ninf(float %arg) {
}
define float @assume_false_pinf(float %arg) {
-; CHECK-LABEL: define float @assume_false_pinf(
-; CHECK-SAME: float returned [[ARG:%.*]]) #[[ATTR3]] {
+; CHECK-LABEL: define nofpclass(all) float @assume_false_pinf(
+; CHECK-SAME: float returned nofpclass(all) [[ARG:%.*]]) #[[ATTR3]] {
; CHECK-NEXT: call void @llvm.assume(i1 noundef false) #[[ATTR5]]
; CHECK-NEXT: ret float [[ARG]]
;
@@ -2539,8 +2539,8 @@ define float @assume_false_pinf(float %arg) {
}
define float @assume_false_ninf(float %arg) {
-; CHECK-LABEL: define float @assume_false_ninf(
-; CHECK-SAME: float returned [[ARG:%.*]]) #[[ATTR3]] {
+; CHECK-LABEL: define nofpclass(all) float @assume_false_ninf(
+; CHECK-SAME: float returned nofpclass(all) [[ARG:%.*]]) #[[ATTR3]] {
; CHECK-NEXT: call void @llvm.assume(i1 noundef false) #[[ATTR5]]
; CHECK-NEXT: ret float [[ARG]]
;
@@ -2580,8 +2580,8 @@ define float @clamp_false_smallest_normal_0.0(float %arg) {
}
define float @assume_false_p0(float %arg) {
-; CHECK-LABEL: define float @assume_false_p0(
-; CHECK-SAME: float returned [[ARG:%.*]]) #[[ATTR3]] {
+; CHECK-LABEL: define nofpclass(all) float @assume_false_p0(
+; CHECK-SAME: float returned nofpclass(all) [[ARG:%.*]]) #[[ATTR3]] {
; CHECK-NEXT: call void @llvm.assume(i1 noundef false) #[[ATTR5]]
; CHECK-NEXT: ret float [[ARG]]
;
@@ -2591,8 +2591,8 @@ define float @assume_false_p0(float %arg) {
}
define float @assume_false_n0(float %arg) {
-; CHECK-LABEL: define float @assume_false_n0(
-; CHECK-SAME: float returned [[ARG:%.*]]) #[[ATTR3]] {
+; CHECK-LABEL: define nofpclass(all) float @assume_false_n0(
+; CHECK-SAME: float returned nofpclass(all) [[ARG:%.*]]) #[[ATTR3]] {
; CHECK-NEXT: call void @llvm.assume(i1 noundef false) #[[ATTR5]]
; CHECK-NEXT: ret float [[ARG]]
;
@@ -2602,8 +2602,8 @@ define float @assume_false_n0(float %arg) {
}
define float @assume_false_smallest_normal(float %arg) {
-; CHECK-LABEL: define float @assume_false_smallest_normal(
-; CHECK-SAME: float returned [[ARG:%.*]]) #[[ATTR3]] {
+; CHECK-LABEL: define nofpclass(all) float @assume_false_smallest_normal(
+; CHECK-SAME: float returned nofpclass(all) [[ARG:%.*]]) #[[ATTR3]] {
; CHECK-NEXT: call void @llvm.assume(i1 noundef false) #[[ATTR5]]
; CHECK-NEXT: ret float [[ARG]]
;
@@ -2727,7 +2727,7 @@ define float @assume_true_smallest_normal(float %arg) {
define float @clamp_true_pinf_0.0(float %arg) {
; CHECK-LABEL: define noundef nofpclass(nan inf nzero sub norm) float @clamp_true_pinf_0.0(
-; CHECK-SAME: float [[ARG:%.*]]) #[[ATTR2]] {
+; CHECK-SAME: float nofpclass(nan inf nzero sub norm) [[ARG:%.*]]) #[[ATTR2]] {
; CHECK-NEXT: ret float 0.000000e+00
;
%fcmp = fcmp true float %arg, 0x7FF0000000000000
@@ -2737,7 +2737,7 @@ define float @clamp_true_pinf_0.0(float %arg) {
define float @clamp_true_ninf_0.0(float %arg) {
; CHECK-LABEL: define noundef nofpclass(nan inf nzero sub norm) float @clamp_true_ninf_0.0(
-; CHECK-SAME: float [[ARG:%.*]]) #[[ATTR2]] {
+; CHECK-SAME: float nofpclass(nan inf nzero sub norm) [[ARG:%.*]]) #[[ATTR2]] {
; CHECK-NEXT: ret float 0.000000e+00
;
%fcmp = fcmp true float %arg, 0xFFF0000000000000
@@ -2747,7 +2747,7 @@ define float @clamp_true_ninf_0.0(float %arg) {
define float @clamp_true_smallest_normal_0.0(float %arg) {
; CHECK-LABEL: define noundef nofpclass(nan inf nzero sub norm) float @clamp_true_smallest_normal_0.0(
-; CHECK-SAME: float [[ARG:%.*]]) #[[ATTR2]] {
+; CHECK-SAME: float nofpclass(nan inf nzero sub norm) [[ARG:%.*]]) #[[ATTR2]] {
; CHECK-NEXT: ret float 0.000000e+00
;
%fcmp = fcmp true float %arg, 0x3810000000000000
@@ -2757,7 +2757,7 @@ define float @clamp_true_smallest_normal_0.0(float %arg) {
define float @clamp_true_nan(float %arg) {
; CHECK-LABEL: define noundef nofpclass(nan inf nzero sub norm) float @clamp_true_nan(
-; CHECK-SAME: float [[ARG:%.*]]) #[[ATTR2]] {
+; CHECK-SAME: float nofpclass(nan inf nzero sub norm) [[ARG:%.*]]) #[[ATTR2]] {
; CHECK-NEXT: ret float 0.000000e+00
;
%fcmp = fcmp true float %arg, 0x7FF8000000000000
@@ -2767,7 +2767,7 @@ define float @clamp_true_nan(float %arg) {
define float @clamp_true_p0(float %arg) {
; CHECK-LABEL: define noundef nofpclass(nan inf nzero sub norm) float @clamp_true_p0(
-; CHECK-SAME: float [[ARG:%.*]]) #[[ATTR2]] {
+; CHECK-SAME: float nofpclass(nan inf nzero sub norm) [[ARG:%.*]]) #[[ATTR2]] {
; CHECK-NEXT: ret float 0.000000e+00
;
%fcmp = fcmp true float %arg, 0.0
@@ -2777,7 +2777,7 @@ define float @clamp_true_p0(float %arg) {
define float @clamp_true_n0(float %arg) {
; CHECK-LABEL: define noundef nofpclass(nan inf nzero sub norm) float @clamp_true_n0(
-; CHECK-SAME: float [[ARG:%.*]]) #[[ATTR2]] {
+; CHECK-SAME: float nofpclass(nan inf nzero sub norm) [[ARG:%.*]]) #[[ATTR2]] {
; CHECK-NEXT: ret float 0.000000e+00
;
%fcmp = fcmp true float %arg, -0.0
More information about the llvm-commits
mailing list