[llvm] 35ab0c7 - ValueTracking: Add tests fcmpToClassTest for fcmp true/false

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 22 21:11:13 PST 2024


Author: Matt Arsenault
Date: 2024-01-23T12:10:31+07:00
New Revision: 35ab0c78cf5f2294e251a6fb1e0d6e58dc80d955

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

LOG: ValueTracking: Add tests fcmpToClassTest for fcmp true/false

Added: 
    

Modified: 
    llvm/test/Transforms/Attributor/nofpclass-implied-by-fcmp.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/Attributor/nofpclass-implied-by-fcmp.ll b/llvm/test/Transforms/Attributor/nofpclass-implied-by-fcmp.ll
index ea594398c58014..8c7d58bf43d6cf 100644
--- a/llvm/test/Transforms/Attributor/nofpclass-implied-by-fcmp.ll
+++ b/llvm/test/Transforms/Attributor/nofpclass-implied-by-fcmp.ll
@@ -2395,5 +2395,291 @@ define float @assume_oeq_smallest_normal_known_pos(float nofpclass(ninf nsub nno
   ret float %arg
 }
 
+;---------------------------------------------------------------------
+; fcmp false
+;---------------------------------------------------------------------
+
+define float @assume_fabs_false_pinf(float %arg) {
+; CHECK-LABEL: define nofpclass(ninf nzero nsub nnorm) float @assume_fabs_false_pinf(
+; CHECK-SAME: float returned nofpclass(ninf nzero nsub nnorm) [[ARG:%.*]]) #[[ATTR3]] {
+; CHECK-NEXT:    call void @llvm.assume(i1 noundef false) #[[ATTR5]]
+; CHECK-NEXT:    ret float [[ARG]]
+;
+  %fabs = call float @llvm.fabs.f32(float %arg)
+  %fcmp = fcmp false float %fabs, 0x7FF0000000000000
+  call void @llvm.assume(i1 %fcmp)
+  ret float %arg
+}
+
+define float @assume_fabs_false_ninf(float %arg) {
+; CHECK-LABEL: define nofpclass(ninf nzero nsub nnorm) float @assume_fabs_false_ninf(
+; CHECK-SAME: float returned nofpclass(ninf nzero nsub nnorm) [[ARG:%.*]]) #[[ATTR3]] {
+; CHECK-NEXT:    call void @llvm.assume(i1 noundef false) #[[ATTR5]]
+; CHECK-NEXT:    ret float [[ARG]]
+;
+  %fabs = call float @llvm.fabs.f32(float %arg)
+  %fcmp = fcmp false float %fabs, 0xFFF0000000000000
+  call void @llvm.assume(i1 %fcmp)
+  ret float %arg
+}
+
+define float @assume_false_pinf(float %arg) {
+; CHECK-LABEL: define float @assume_false_pinf(
+; CHECK-SAME: float returned [[ARG:%.*]]) #[[ATTR3]] {
+; CHECK-NEXT:    call void @llvm.assume(i1 noundef false) #[[ATTR5]]
+; CHECK-NEXT:    ret float [[ARG]]
+;
+  %fcmp = fcmp false float %arg, 0x7FF0000000000000
+  call void @llvm.assume(i1 %fcmp)
+  ret float %arg
+}
+
+define float @assume_false_ninf(float %arg) {
+; CHECK-LABEL: define float @assume_false_ninf(
+; CHECK-SAME: float returned [[ARG:%.*]]) #[[ATTR3]] {
+; CHECK-NEXT:    call void @llvm.assume(i1 noundef false) #[[ATTR5]]
+; CHECK-NEXT:    ret float [[ARG]]
+;
+  %fcmp = fcmp false float %arg, 0xFFF0000000000000
+  call void @llvm.assume(i1 %fcmp)
+  ret float %arg
+}
+
+define float @clamp_false_pinf_0.0(float %arg) {
+; CHECK-LABEL: define float @clamp_false_pinf_0.0(
+; CHECK-SAME: float returned [[ARG:%.*]]) #[[ATTR2]] {
+; CHECK-NEXT:    ret float [[ARG]]
+;
+  %fcmp = fcmp false float %arg, 0x7FF0000000000000
+  %select = select i1 %fcmp, float 0.0, float %arg
+  ret float %select
+}
+
+define float @clamp_false_ninf_0.0(float %arg) {
+; CHECK-LABEL: define float @clamp_false_ninf_0.0(
+; CHECK-SAME: float returned [[ARG:%.*]]) #[[ATTR2]] {
+; CHECK-NEXT:    ret float [[ARG]]
+;
+  %fcmp = fcmp false float %arg, 0xFFF0000000000000
+  %select = select i1 %fcmp, float 0.0, float %arg
+  ret float %select
+}
+
+define float @clamp_false_smallest_normal_0.0(float %arg) {
+; CHECK-LABEL: define float @clamp_false_smallest_normal_0.0(
+; CHECK-SAME: float returned [[ARG:%.*]]) #[[ATTR2]] {
+; CHECK-NEXT:    ret float [[ARG]]
+;
+  %fcmp = fcmp false float %arg, 0x3810000000000000
+  %select = select i1 %fcmp, float 0.0, float %arg
+  ret float %select
+}
+
+define float @assume_false_p0(float %arg) {
+; CHECK-LABEL: define float @assume_false_p0(
+; CHECK-SAME: float returned [[ARG:%.*]]) #[[ATTR3]] {
+; CHECK-NEXT:    call void @llvm.assume(i1 noundef false) #[[ATTR5]]
+; CHECK-NEXT:    ret float [[ARG]]
+;
+  %fcmp = fcmp false float %arg, 0.0
+  call void @llvm.assume(i1 %fcmp)
+  ret float %arg
+}
+
+define float @assume_false_n0(float %arg) {
+; CHECK-LABEL: define float @assume_false_n0(
+; CHECK-SAME: float returned [[ARG:%.*]]) #[[ATTR3]] {
+; CHECK-NEXT:    call void @llvm.assume(i1 noundef false) #[[ATTR5]]
+; CHECK-NEXT:    ret float [[ARG]]
+;
+  %fcmp = fcmp false float %arg, -0.0
+  call void @llvm.assume(i1 %fcmp)
+  ret 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-NEXT:    call void @llvm.assume(i1 noundef false) #[[ATTR5]]
+; CHECK-NEXT:    ret float [[ARG]]
+;
+  %fcmp = fcmp false float %arg, 0x3810000000000000
+  call void @llvm.assume(i1 %fcmp)
+  ret float %arg
+}
+
+define float @clamp_false_nan(float %arg) {
+; CHECK-LABEL: define float @clamp_false_nan(
+; CHECK-SAME: float returned [[ARG:%.*]]) #[[ATTR2]] {
+; CHECK-NEXT:    ret float [[ARG]]
+;
+  %fcmp = fcmp false float %arg, 0x7FF8000000000000
+  %select = select i1 %fcmp, float 0.0, float %arg
+  ret float %select
+}
+
+define float @clamp_false_p0(float %arg) {
+; CHECK-LABEL: define float @clamp_false_p0(
+; CHECK-SAME: float returned [[ARG:%.*]]) #[[ATTR2]] {
+; CHECK-NEXT:    ret float [[ARG]]
+;
+  %fcmp = fcmp false float %arg, 0.0
+  %select = select i1 %fcmp, float 0.0, float %arg
+  ret float %select
+}
+
+define float @clamp_false_n0(float %arg) {
+; CHECK-LABEL: define float @clamp_false_n0(
+; CHECK-SAME: float returned [[ARG:%.*]]) #[[ATTR2]] {
+; CHECK-NEXT:    ret float [[ARG]]
+;
+  %fcmp = fcmp false float %arg, -0.0
+  %select = select i1 %fcmp, float 0.0, float %arg
+  ret float %select
+}
+
+;---------------------------------------------------------------------
+; fcmp true
+;---------------------------------------------------------------------
+
+define float @assume_fabs_true_pinf(float %arg) {
+; CHECK-LABEL: define nofpclass(ninf nzero nsub nnorm) float @assume_fabs_true_pinf(
+; CHECK-SAME: float returned nofpclass(ninf nzero nsub nnorm) [[ARG:%.*]]) #[[ATTR3]] {
+; CHECK-NEXT:    call void @llvm.assume(i1 noundef true) #[[ATTR5]]
+; CHECK-NEXT:    ret float [[ARG]]
+;
+  %fabs = call float @llvm.fabs.f32(float %arg)
+  %fcmp = fcmp true float %fabs, 0x7FF0000000000000
+  call void @llvm.assume(i1 %fcmp)
+  ret float %arg
+}
+
+define float @assume_fabs_true_ninf(float %arg) {
+; CHECK-LABEL: define nofpclass(ninf nzero nsub nnorm) float @assume_fabs_true_ninf(
+; CHECK-SAME: float returned nofpclass(ninf nzero nsub nnorm) [[ARG:%.*]]) #[[ATTR3]] {
+; CHECK-NEXT:    call void @llvm.assume(i1 noundef true) #[[ATTR5]]
+; CHECK-NEXT:    ret float [[ARG]]
+;
+  %fabs = call float @llvm.fabs.f32(float %arg)
+  %fcmp = fcmp true float %fabs, 0xFFF0000000000000
+  call void @llvm.assume(i1 %fcmp)
+  ret float %arg
+}
+
+define float @assume_true_pinf(float %arg) {
+; CHECK-LABEL: define float @assume_true_pinf(
+; CHECK-SAME: float returned [[ARG:%.*]]) #[[ATTR3]] {
+; CHECK-NEXT:    call void @llvm.assume(i1 noundef true) #[[ATTR5]]
+; CHECK-NEXT:    ret float [[ARG]]
+;
+  %fcmp = fcmp true float %arg, 0x7FF0000000000000
+  call void @llvm.assume(i1 %fcmp)
+  ret float %arg
+}
+
+define float @assume_true_ninf(float %arg) {
+; CHECK-LABEL: define float @assume_true_ninf(
+; CHECK-SAME: float returned [[ARG:%.*]]) #[[ATTR3]] {
+; CHECK-NEXT:    call void @llvm.assume(i1 noundef true) #[[ATTR5]]
+; CHECK-NEXT:    ret float [[ARG]]
+;
+  %fcmp = fcmp true float %arg, 0xFFF0000000000000
+  call void @llvm.assume(i1 %fcmp)
+  ret float %arg
+}
+
+define float @assume_true_p0(float %arg) {
+; CHECK-LABEL: define float @assume_true_p0(
+; CHECK-SAME: float returned [[ARG:%.*]]) #[[ATTR3]] {
+; CHECK-NEXT:    call void @llvm.assume(i1 noundef true) #[[ATTR5]]
+; CHECK-NEXT:    ret float [[ARG]]
+;
+  %fcmp = fcmp true float %arg, 0.0
+  call void @llvm.assume(i1 %fcmp)
+  ret float %arg
+}
+
+define float @assume_true_n0(float %arg) {
+; CHECK-LABEL: define float @assume_true_n0(
+; CHECK-SAME: float returned [[ARG:%.*]]) #[[ATTR3]] {
+; CHECK-NEXT:    call void @llvm.assume(i1 noundef true) #[[ATTR5]]
+; CHECK-NEXT:    ret float [[ARG]]
+;
+  %fcmp = fcmp true float %arg, -0.0
+  call void @llvm.assume(i1 %fcmp)
+  ret float %arg
+}
+
+define float @assume_true_smallest_normal(float %arg) {
+; CHECK-LABEL: define float @assume_true_smallest_normal(
+; CHECK-SAME: float returned [[ARG:%.*]]) #[[ATTR3]] {
+; CHECK-NEXT:    call void @llvm.assume(i1 noundef true) #[[ATTR5]]
+; CHECK-NEXT:    ret float [[ARG]]
+;
+  %fcmp = fcmp true float %arg, 0x3810000000000000
+  call void @llvm.assume(i1 %fcmp)
+  ret 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-NEXT:    ret float 0.000000e+00
+;
+  %fcmp = fcmp true float %arg, 0x7FF0000000000000
+  %select = select i1 %fcmp, float 0.0, float %arg
+  ret float %select
+}
+
+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-NEXT:    ret float 0.000000e+00
+;
+  %fcmp = fcmp true float %arg, 0xFFF0000000000000
+  %select = select i1 %fcmp, float 0.0, float %arg
+  ret float %select
+}
+
+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-NEXT:    ret float 0.000000e+00
+;
+  %fcmp = fcmp true float %arg, 0x3810000000000000
+  %select = select i1 %fcmp, float 0.0, float %arg
+  ret float %select
+}
+
+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-NEXT:    ret float 0.000000e+00
+;
+  %fcmp = fcmp true float %arg, 0x7FF8000000000000
+  %select = select i1 %fcmp, float 0.0, float %arg
+  ret float %select
+}
+
+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-NEXT:    ret float 0.000000e+00
+;
+  %fcmp = fcmp true float %arg, 0.0
+  %select = select i1 %fcmp, float 0.0, float %arg
+  ret float %select
+}
+
+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-NEXT:    ret float 0.000000e+00
+;
+  %fcmp = fcmp true float %arg, -0.0
+  %select = select i1 %fcmp, float 0.0, float %arg
+  ret float %select
+}
+
 ;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
 ; TUNIT: {{.*}}


        


More information about the llvm-commits mailing list