Simplify RTX comparisons of bitwise operations with constants.
GCC now simplifies certain comparisons involving bitwise AND/OR operations with constants, potentially fixing an ICE on RISC-V.
This patch introduces simplifications for expressions of the form (cmp (and/ior x C1) C2) within GCC’s simplify-rtx pass. By analyzing the relationships between the constants C1 and C2, the compiler can determine cases where the comparison can never be true, allowing for optimization. This change addresses a reported internal compiler error (ICE) on RISC-V and improves code generation in specific scenarios.
In Details
The simplify-rtx pass in GCC aims to simplify RTL expressions. This patch modifies simplify_relational_operation_1 function to handle specific patterns involving comparisons of bitwise AND/OR operations with constants. The goal is to optimize these expressions before instruction splitting, potentially avoiding issues like the reported ICE on RISC-V related to instruction condition changes.
For Context
The "simplify-rtx" pass in GCC is responsible for simplifying Register Transfer Language (RTL) expressions, an intermediate representation used during compilation. This pass identifies opportunities to rewrite complex expressions into simpler, equivalent forms, leading to more efficient code generation. This patch focuses on simplifying comparisons involving bitwise AND/OR operations with constant values, allowing GCC to optimize code that uses these patterns.