diff options
author | Jakub Jelinek <jakub@redhat.com> | 2025-07-31 12:10:02 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2025-07-31 12:10:45 +0200 |
commit | e624d5559d21992c9e5da85b4ae75629a61afc2c (patch) | |
tree | 0c6a908ee1807056196622dad16d91230b87f28d /gcc/rust/parse/rust-parse-impl.h | |
parent | 9793ffce9332349441b5c83f8c1809ac4264a0f2 (diff) | |
download | gcc-e624d5559d21992c9e5da85b4ae75629a61afc2c.zip gcc-e624d5559d21992c9e5da85b4ae75629a61afc2c.tar.gz gcc-e624d5559d21992c9e5da85b4ae75629a61afc2c.tar.bz2 |
change get_best_mode args int -> HOST_WIDE_INT [PR121264]
The following testcase is miscompiled, because byte 0x20000000
is bit 0x100000000 and ifcombine incorrectly combines the two loads
into a BIT_FIELD_REF even when they are very far away.
The problem is that gimple-fold.cc ifcombine uses get_best_mode heavily,
and that function has just int bitsize and int bitpos arguments, so
when called e.g. with
if (get_best_mode (end_bit - first_bit, first_bit, 0, ll_end_region,
ll_align, BITS_PER_WORD, volatilep, &lnmode))
where end_bit - first_bit doesn't fit into int, it is silently truncated.
If there was just a single problematic get_best_mode call, I would probably
just check for overflows in the caller, but there are many.
And the two arguments are used solely as arguments to
bit_field_mode_iterator constructor which has HOST_WIDE_INT arguments,
so I think the easiest fix is just make the get_best_mode arguments
also HOST_WIDE_INT.
2025-07-31 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/121264
* machmode.h (get_best_mode): Change type of first 2 arguments
from int to HOST_WIDE_INT.
* stor-layout.cc (get_best_mode): Likewise.
* gcc.dg/tree-ssa/pr121264.c: New test.
Diffstat (limited to 'gcc/rust/parse/rust-parse-impl.h')
0 files changed, 0 insertions, 0 deletions