Fix combine_comparisons for vector(signed) boolean types
Correctly combines signed vector boolean comparisons, fixing incorrect results for LT/LE/GT/GE.
This commit rectifies an issue in combine_comparisons where signed vector boolean types were handled incorrectly, leading to faulty optimizations for less-than and greater-than comparisons. The fix introduces support for signed boolean types, ensuring that operations like LT, LE, GT, and GE produce accurate results by distinguishing them from their unsigned counterparts. This change required updates across multiple GIMPLE folding functions to pass the new type information.
In Details
The combine_comparisons function in fold-const.cc previously assumed unsigned boolean types (0/1) when combining comparison operations. This commit adds a new inner_truth_type argument to differentiate between unsigned and signed boolean types (0/-1). Signed booleans require different logic for LT/LE/GT/GE operations, as their interpretation differs from unsigned types. The patch propagates this argument through various GIMPLE folding routines to correctly handle these signed vector comparisons.
- combine_comparisons
- A function in GCC's constant folding logic that attempts to combine multiple comparison operations into a single, simpler expression.
- vector boolean types
- Data types representing a collection of boolean values, often used in SIMD operations. Signed boolean types typically use 0 for false and -1 for true, while unsigned use 0 for false and 1 for true.
- GIMPLE
- GCC's internal three-address code representation, used for optimization passes. It's a simplified intermediate representation derived from the compiler's parse tree.