diff options
author | Jakub Jelinek <jakub@redhat.com> | 2024-02-02 11:25:13 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2024-02-02 11:26:43 +0100 |
commit | a8f335ccb61bf6105192a4197ef2d84900614dc1 (patch) | |
tree | 915006764b475a9478bbe6bbfd9622ece87056f4 /gcc/go | |
parent | e5b14d956e38d88542d51bdb697f2161838d1b67 (diff) | |
download | gcc-a8f335ccb61bf6105192a4197ef2d84900614dc1.zip gcc-a8f335ccb61bf6105192a4197ef2d84900614dc1.tar.gz gcc-a8f335ccb61bf6105192a4197ef2d84900614dc1.tar.bz2 |
tree-ssa-math-opts: Fix is_widening_mult_rhs_p - unbreak bootstrap [PR113705]
On Tue, Jan 30, 2024 at 07:33:10AM -0000, Roger Sayle wrote:
+ wide_int bits = wide_int::from (tree_nonzero_bits (rhs),
+ prec,
+ TYPE_SIGN (TREE_TYPE (rhs)));
...
> + if (gimple_assign_rhs_code (stmt) == BIT_AND_EXPR
> + && TREE_CODE (gimple_assign_rhs2 (stmt)) == INTEGER_CST
> + && wi::to_wide (gimple_assign_rhs2 (stmt))
> + == wi::mask (hprec, false, prec))
This change broke bootstrap on aarch64-linux.
The problem can be seen even on the reduced testcase.
The IL on the unreduced testcase before widening_mul has:
# val_583 = PHI <val_26(13), val_164(40)>
...
pretmp_266 = MEM[(const struct wide_int_storage *)&D.160657].len;
_264 = pretmp_266 & 65535;
...
_176 = (sizetype) val_583;
_439 = (sizetype) _264;
_284 = _439 * 8;
_115 = _176 + _284;
where 583/266/264 have unsigned int type and 176/439/284/115 have sizetype.
widening_mul first turns that into:
# val_583 = PHI <val_26(13), val_164(40)>
...
pretmp_266 = MEM[(const struct wide_int_storage *)&D.160657].len;
_264 = pretmp_266 & 65535;
...
_176 = (sizetype) val_583;
_439 = (sizetype) _264;
_284 = _264 w* 8;
_115 = _176 + _284;
and then is_widening_mult_rhs_p is called, with type sizetype (64-bit),
rhs _264, hprec 32 and prec 64. Now tree_nonzero_bits (rhs) is
65535, so bits is 64-bit wide_int 65535, stmt is BIT_AND_EXPR,
but we ICE on the
wi::to_wide (gimple_assign_rhs2 (stmt)) == wi::mask (hprec, false, prec)
comparison because wi::to_wide on gimple_assign_rhs2 (stmt) - unsigned int
65535 gives 32-bit wide_int 65535, while wi::mask (hprec, false, prec)
gives 64-bit wide_int 0xffffffff and comparison between different precision
wide_ints is forbidden.
The following patch fixes it the same way how bits is computed earlier,
by calling wide_int::from on the wi::to_wide (gimple_assign_rhs2 (stmt)),
so we compare 64-bit 65535 with 64-bit 0xffffffff.
2024-02-02 Jakub Jelinek <jakub@redhat.com>
PR middle-end/113705
* tree-ssa-math-opts.cc (is_widening_mult_rhs_p): Use wide_int_from
around wi::to_wide in order to compare value in prec precision.
* g++.dg/opt/pr113705.C: New test.
Diffstat (limited to 'gcc/go')
0 files changed, 0 insertions, 0 deletions