[gcc r16-6756] match: Remove redundant type checks from `(T1)(a bit_op (T2)b)` pattern.
Andrew Pinski
pinskia@gcc.gnu.org
Tue Jan 13 23:31:02 GMT 2026
https://gcc.gnu.org/g:15b965d6bbb33e1a29ebae58ec167cc20525d43f
commit r16-6756-g15b965d6bbb33e1a29ebae58ec167cc20525d43f
Author: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Date: Tue Jan 13 15:21:56 2026 -0800
match: Remove redundant type checks from `(T1)(a bit_op (T2)b)` pattern.
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>
Diff:
---
gcc/match.pd | 3 ---
1 file changed, 3 deletions(-)
diff --git a/gcc/match.pd b/gcc/match.pd
index 400330aae541..91f92b56b03a 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -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))))))
More information about the Gcc-cvs
mailing list