aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-dom.cc
diff options
context:
space:
mode:
authorRoger Sayle <roger@nextmovesoftware.com>2025-10-15 11:21:18 +0100
committerRoger Sayle <roger@nextmovesoftware.com>2025-10-15 11:21:18 +0100
commitda293ec6b68fab23c44f6643011cf7ae62d93b16 (patch)
tree845a7215a5adc8d556d75be12045d54d1d594f59 /gcc/tree-ssa-dom.cc
parenta93f80feeef744649dc426a59a5860224d13e68d (diff)
downloadgcc-master.zip
gcc-master.tar.gz
gcc-master.tar.bz2
PR rtl-optimization/122266: Handle TImode in reg_num_sign_bit_copies_for_combineHEADtrunkmaster
This patch resolves PR rtl-optimization/122266 by changing the types of the last_set_sign_bit_copies and sign_bit_copies fields in combine.cc's reg_stat_type struct to be "unsigned short". This makes both types consistent, and fixes the issue that on platforms where char is by default signed, combine.cc can overflow when handling TImode values, where sign_bit_copies can be 128 bits. Conveniently, there are holes (caused by field alignment/padding) in the reg_stat_type struct that allows us to upgrade to "unsigned short" without increasing the total size of the struct. This should help reduce problems in future handling OImode or XImode values, or possible issues with 256-bit and 512-bit vector modes. Note that it's important to take care when reordering the fields of this struct, as the (partial) ordering of fields is significant: See the use of offsetof in combine.cc's init_reg_last. Before: (gdb) ptype /o reg_stat_type /* offset | size */ type = struct reg_stat_type { /* 0 | 8 */ rtx_insn *last_death; /* 8 | 8 */ rtx_insn *last_set; /* 16 | 8 */ rtx last_set_value; /* 24 | 4 */ int last_set_table_tick; /* 28 | 4 */ int last_set_label; /* 32 | 8 */ unsigned long last_set_nonzero_bits; /* 40 | 1 */ char last_set_sign_bit_copies; /* 41: 0 | 4 */ machine_mode last_set_mode : 16; /* 43 | 1 */ bool last_set_invalid; /* 44 | 1 */ unsigned char sign_bit_copies; /* XXX 3-byte hole */ /* 48 | 8 */ unsigned long nonzero_bits; /* 56 | 4 */ int truncation_label; /* 60: 0 | 4 */ machine_mode truncated_to_mode : 16; /* XXX 2-byte padding */ /* total size (bytes): 64 */ } After: /* offset | size */ type = struct reg_stat_type { /* 0 | 8 */ rtx_insn *last_death; /* 8 | 8 */ rtx_insn *last_set; /* 16 | 8 */ rtx last_set_value; /* 24 | 4 */ int last_set_table_tick; /* 28 | 4 */ int last_set_label; /* 32 | 8 */ unsigned long last_set_nonzero_bits; /* 40 | 2 */ unsigned short last_set_sign_bit_copies; /* 42: 0 | 4 */ machine_mode last_set_mode : 16; /* 44 | 1 */ bool last_set_invalid; /* XXX 1-byte hole */ /* 46 | 2 */ unsigned short sign_bit_copies; /* 48 | 8 */ unsigned long nonzero_bits; /* 56 | 4 */ int truncation_label; /* 60: 0 | 4 */ machine_mode truncated_to_mode : 16; /* XXX 2-byte padding */ /* total size (bytes): 64 */ } 2025-10-15 Roger Sayle <roger@nextmovesoftware.com> gcc/ChangeLog PR rtl-optimization/122266 * combine.cc (struct reg_stat_type): Change types of sign_bit_copies and last_set_sign_bit_copies to unsigned short, to avoid overflows on TImode (and wider) values. gcc/testsuite/ChangeLog PR rtl-optimization/122266 * gcc.target/i386/pr122266.c: New test case.
Diffstat (limited to 'gcc/tree-ssa-dom.cc')
0 files changed, 0 insertions, 0 deletions