diff options
author | Jakub Jelinek <jakub@redhat.com> | 2025-04-14 19:34:22 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2025-04-14 19:34:22 +0200 |
commit | f96a54350afcf7f3c90d0ecb51d7683d826acc00 (patch) | |
tree | d6dbdac55917d567f523034fc9d9745a93ece505 /gcc | |
parent | e0b57c75e6daa1664bea03ce96733bf1ebb38ced (diff) | |
download | gcc-f96a54350afcf7f3c90d0ecb51d7683d826acc00.zip gcc-f96a54350afcf7f3c90d0ecb51d7683d826acc00.tar.gz gcc-f96a54350afcf7f3c90d0ecb51d7683d826acc00.tar.bz2 |
expmed: Always use QImode for init_expmed set_zero_cost [PR119785]
This is a regression on some targets introduced I believe by r6-2055
which added mode argument to set_src_cost.
The problem here is that in the first iteration, mode is always QImode
and we get as -Os zero cost set_src_cost (const0_rtx, QImode, false).
But then we use the mode variable for iterating over int, partial int
and vector int modes, so for the second iteration we call set_src_cost
with mode which is at that time (machine_mode) (MAX_MODE_VECTOR_INT + 1).
In the x86 case that happens to be V2HFmode and we don't crash (and
compute the same 0 cost as we would for QImode).
But e.g. in the SPARC case (machine_mode) (MAX_MODE_VECTOR_INT + 1) is
MAX_MACHINE_MODE and that does all kinds of weird things especially
when doing ubsan bootstrap.
Fixed by always using QImode.
2025-04-14 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/119785
* expmed.cc (init_expmed): Always pass QImode rather than mode to
set_src_cost passed to set_zero_cost.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/expmed.cc | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/expmed.cc b/gcc/expmed.cc index df09cbc..8cf10d9 100644 --- a/gcc/expmed.cc +++ b/gcc/expmed.cc @@ -285,7 +285,7 @@ init_expmed (void) for (speed = 0; speed < 2; speed++) { crtl->maybe_hot_insn_p = speed; - set_zero_cost (speed, set_src_cost (const0_rtx, mode, speed)); + set_zero_cost (speed, set_src_cost (const0_rtx, QImode, speed)); for (mode = MIN_MODE_INT; mode <= MAX_MODE_INT; mode = (machine_mode)(mode + 1)) |