match.pd: Check operand precision for cond_expr_convert_p
Ensures that arms of conditional expressions in match.pd have compatible precision to avoid compiler ICEs.
This commit enhances the cond_expr_convert_p in match.pd to correctly handle operand precision. Previously, it only checked TYPE_SIZE, which could lead to an internal compiler error (ICE) during range analysis when integral operands of different precisions (e.g., _BitInt(17) vs unsigned int) were compared. The check now ensures that integral arms are convertible to each other, allowing for differences in sign.
In Details
The cond_expr_convert_p predicate in match.pd is updated to use tree_nop_conversion_p instead of INTEGRAL_TYPE_P when comparing integral operands of a COND_EXPR. This prevents the generation of COND_EXPR where arms have differing precision, such as unsigned _BitInt(17) and unsigned int. Such discrepancies caused ICEs in subsequent range analysis passes. The new check ensures that the integral arms are at least nop-convertible, allowing for sign differences.
- match.pd
- A file within GCC that contains pattern-matching definitions for optimizing instruction selection. It uses a declarative language to describe patterns in the intermediate representation.
- COND_EXPR
- GCC's internal representation for a conditional expression (ternary operator
?:). - ICE
- Internal Compiler Error. A crash within the compiler itself, usually indicating a bug in the compiler's logic.
- tree_nop_conversion_p
- A GCC internal function that checks if one type can be converted to another without any actual data modification or loss of precision.
- _BitInt
- A GCC extension for arbitrary-precision integers, allowing users to specify integers of non-standard bit widths.