CT_00_043 - Extension Elimination (GCC)
About
These are tasks carried forward from 2024 and some additional work identified in 2024
Use Jivan's trick to expose the sign extended nature of SI/HI/QI mode return values.
A signed comparison of a sign extended SI subreg against a constant with 0x8000000 clear can be turned into unsigned comparison in DImode
This is a generalization of the min/max case that's currently handled in bitmanip.md.
Investigate if we're already handling this (we may be), and if not explore the best way to fix
Investigate Ajit's work (IBM) to exploit cases where masking can be viewed as zero-extension within REE
In REE handle cases like (any_extend:DI (ashift:SI )) where the extension can be replaced by a SUBREG and then push the SUBREG into the operands generating word sized operations. This helps code like this:
void foo(unsigned char *data, unsigned int lo_bit) {
unsigned int mask = ((1UL << 1) - 1) << lo_bit;
*data = (*data & ~mask) | ((1 << lo_bit) & mask);
}
One the unnecessary extension is eliminated a simple backend pattern can be used to simplify all that to a simple lb+bset+sb.
Current thinking (March 2025) is that we could have ext-dce replace the explicit sign/zero extensions on left shift operations with a subreg (or push the subreg to the operands). That in turn should provide just enough information to allow combine to discover more
Stakeholders/Partners
RISE:
Ventana: Jeff Law
Rivos: Vineet (part time)
External:
Dependencies
Status
Development | NOT STARTED |
|
|---|---|---|
Development Timeline | 1H2025 |
|
Upstreaming | NOT STARTED |
|
Upstream Version | gcc-16 Spring 2026
|
|
Contacts | Jeff Law (Ventana) |
|
Dependencies | None |
|
Updates
Nov 7, 2024
New/incomplete items moved into 1H2025