]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
match: Remove redundant type checks from `(T1)(a bit_op (T2)b)` pattern.
authorAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Tue, 13 Jan 2026 23:21:56 +0000 (15:21 -0800)
committerAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Tue, 13 Jan 2026 23:21:56 +0000 (15:21 -0800)
As mentioned in https://gcc.gnu.org/pipermail/gcc-patches/2026-January/705657.html,
there were some redundant checks in this pattern. In the first if,
the check for pointer and OFFSET_TYPE is redundant as there is a check for
INTEGRAL_TYPE_P before hand. For the second one, the check for INTEGRAL_TYPE_P
on the inner most type is not needed as there is a types_match right afterwards

Pushed as obvious after bootstra/test on x86_64-linux-gnu.

gcc/ChangeLog:

* match.pd (`(T1)(a bit_op (T2)b)`): Remove redundant
type checks.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
gcc/match.pd

index 400330aae5416df56660b03a99b42e9ad7714e6e..91f92b56b03a0d07199de8fdaad622e33bd2a1da 100644 (file)
@@ -2320,15 +2320,12 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
        && INTEGRAL_TYPE_P (TREE_TYPE (@0))
        && TREE_CODE (@1) != INTEGER_CST
        && tree_nop_conversion_p (type, TREE_TYPE (@2))
-       && !POINTER_TYPE_P (TREE_TYPE (@0))
-       && TREE_CODE (TREE_TYPE (@0)) != OFFSET_TYPE
        && TYPE_PRECISION (TREE_TYPE (@0)) > TYPE_PRECISION (type))
    (bitop:type (convert @0) (convert @1))
    /* Similar as above, but the outer and inner most types match
        and it was widening cast; replacing 2 casts with only one.  */
    (if (GIMPLE
         && INTEGRAL_TYPE_P (type)
-        && INTEGRAL_TYPE_P (TREE_TYPE (@0))
         && types_match (type, TREE_TYPE (@0))
         && TYPE_PRECISION (TREE_TYPE (@2)) > TYPE_PRECISION (type))
     (bitop:type @0 (convert @1))))))