tree-ssa: Canonicalize arithmetic overflow IFN operands
Canonicalizes operands for arithmetic overflow internal functions to improve consistency.
This change canonicalizes the operands of commutative arithmetic overflow internal functions, such as ADD_OVERFLOW. Previously, the order of operands could be non-canonical, potentially disagreeing with related addition operations. By using tree_swap_operands_p, the operands are now ordered consistently, improving the predictability of optimization passes and reducing potential discrepancies in generated code. This also applies to MUL_OVERFLOW, while SUB_OVERFLOW retains its original order as it is not commutative. A new test case for aarch64 verifies this behavior.
In Details
Canonicalizes operands for commutative arithmetic overflow internal functions in tree-ssa. Uses tree_swap_operands_p to ensure operand order matches canonical addition order, improving consistency for subsequent passes like match_arith_overflow. Affects .ADD_OVERFLOW and .MUL_OVERFLOW internal functions.
- tree-ssa
- A compiler intermediate representation (IR) and optimization framework within GCC that represents code in Static Single Assignment (SSA) form. It facilitates various optimizations by providing a structured view of data flow and variable lifetimes.
- internal function
- A function recognized and represented directly within the compiler's intermediate representation, rather than as a standard call to a library function. These often represent primitive operations or specific optimization targets.
- canonicalize
- To transform an expression or data structure into a standard or normal form. In this context, it means ensuring that operands of commutative operations are always presented in a consistent, predictable order.