ifcvt: Handle disjoint live-outs in diamond conversions for ARM
The ifcvt pass now correctly handles conditional diamond conversions on ARM where arms update distinct live-out variables.
The ifcvt (if-conversion) pass has been improved to handle conditional diamond conversions, particularly on ARM, when the two branches of the diamond update different sets of live-out variables. Previously, it required overlapping live-outs, forcing the use of temporary variables for values only defined in one arm. This change allows for more flexible and efficient conversion by correctly managing disjoint live-outs and enabling one-set arms, improving code generation for conditional constructs.
In Details
The ifcvt pass's noce_convert_multiple_sets function is enhanced to support ARM-specific diamond conversions where the 'then' and 'else' branches update disjoint sets of live-out variables. The previous restriction required one arm's live-outs to be a subset of the other's. The fix involves building metadata for both arms, appending 'else'-only live-out destinations as temporaries, and ensuring the conditional move selection correctly merges shared and disjoint live-outs. This resolves PR125557 by allowing conversions where distinct variables are updated in each branch, while still accomm…
- ifcvt
- A compiler optimization pass that converts conditional control flow (if-else statements) into conditional move instructions, potentially improving performance by avoiding branches.
- live-out
- A variable that is live (its value may be used later) after a specific block of code or a function call.
- diamond conversion
- A specific pattern within if-conversion where a conditional branch splits into two paths, which then merge back together. This commit addresses issues in converting such structures.
- ARM
- A family of reduced instruction set computing (RISC) architectures commonly used in mobile devices and embedded systems, and increasingly in servers.