[gcc r17-2804] match: Fix some incorrect vector fp comparison combines [PR 126455]

Andrea Pinski via Gcc-cvs <[email protected]> Thu, 30 Jul 2026 03:53:32 +0000 (GMT)
Newsgroups gmane.comp.gcc.cvs
Message-ID <[email protected]>
https://gcc.gnu.org/g:b13db033a4ee22e920756be0e182c001a1e99dce

commit r17-2804-gb13db033a4ee22e920756be0e182c001a1e99dce
Author: Andrea Pinski <[email protected]>
Date:   Wed Jul 29 16:44:17 2026 -0700

    match: Fix some incorrect vector fp comparison combines [PR 126455]
    
    This fixes r16-2134-gf33cc3af8fd9c4 which extended some patterns to
    support vector types but these patterns are only valid for integral
    types and the check that was used was VECTOR_TYPE.
    This fixes it by using VECTOR_INTEGRAL_TYPE || VECTOR_BOOLCEAN_TYPE
    which prevent the, for vector floating point types.
    
    Pushed as obvious after bootstrap/test on x86_64-linux-gnu.
    
            PR tree-optimization/126455
    
    gcc/ChangeLog:
    
            * match.pd: Fix up patterns dealing with bitwise AND/OR/XOR
            and comparisons for floating point types.
    
    Signed-off-by: Andrea Pinski <[email protected]>

Diff:
---
 gcc/match.pd | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/gcc/match.pd b/gcc/match.pd
index 668fbe70d24d..4b2a360966c9 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -3485,7 +3485,8 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
    (if ((TREE_CODE (@1) == INTEGER_CST
 	 && TREE_CODE (@2) == INTEGER_CST)
 	|| ((INTEGRAL_TYPE_P (TREE_TYPE (@1))
-   || (VECTOR_TYPE_P (TREE_TYPE (@1))
+   || ((VECTOR_INTEGER_TYPE_P (TREE_TYPE (@1))
+	|| VECTOR_BOOLEAN_TYPE_P (TREE_TYPE (@1)))
    && expand_vec_cmp_expr_p (TREE_TYPE (@1), type, code2))
 	     || POINTER_TYPE_P (TREE_TYPE (@1)))
 	    && bitwise_equal_p (@1, @2)))
@@ -3576,7 +3577,8 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
   (if ((TREE_CODE (@1) == INTEGER_CST
 	&& TREE_CODE (@2) == INTEGER_CST)
        || ((INTEGRAL_TYPE_P (TREE_TYPE (@1))
-       || (VECTOR_TYPE_P (TREE_TYPE (@1))
+       || ((VECTOR_INTEGER_TYPE_P (TREE_TYPE (@1))
+	    || VECTOR_BOOLEAN_TYPE_P (TREE_TYPE (@1)))
        && expand_vec_cmp_expr_p (TREE_TYPE (@1), type, code2))
 	    || POINTER_TYPE_P (TREE_TYPE (@1)))
 	   && operand_equal_p (@1, @2)))
@@ -3766,7 +3768,8 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
    (op:c (cmp1:c @0 @1) (cmp2 @0 @1))
    (if (INTEGRAL_TYPE_P (TREE_TYPE (@0))
       || POINTER_TYPE_P (TREE_TYPE (@0))
-      || (VECTOR_TYPE_P (TREE_TYPE (@1))
+      || ((VECTOR_INTEGER_TYPE_P (TREE_TYPE (@1))
+	   || VECTOR_BOOLEAN_TYPE_P (TREE_TYPE (@1)))
       && expand_vec_cmp_expr_p (TREE_TYPE (@0), type, rcmp)))
     (rcmp @0 @1)))))
 
@@ -3778,7 +3781,8 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
   (eq:c (cmp1:c @0 @1) (cmp2 @0 @1))
   (if (INTEGRAL_TYPE_P (TREE_TYPE (@0))
 		|| POINTER_TYPE_P (TREE_TYPE (@0))
-      || (VECTOR_TYPE_P (TREE_TYPE (@0))
+      || ((VECTOR_INTEGER_TYPE_P (TREE_TYPE (@1))
+	   || VECTOR_BOOLEAN_TYPE_P (TREE_TYPE (@1)))
       && expand_vec_cmp_expr_p (TREE_TYPE (@0), type,  rcmp)))
     (rcmp @0 @1))))