]> gcc.gnu.org Git - gcc.git/commit
expmed: Fix store_integral_bit_field [PR101562]
authorJakub Jelinek <jakub@redhat.com>
Fri, 23 Jul 2021 17:55:16 +0000 (19:55 +0200)
committerJakub Jelinek <jakub@redhat.com>
Tue, 10 May 2022 08:14:26 +0000 (10:14 +0200)
commit6cb2b5581d2ca5b4175dc2cf4f32e4251a314eda
treefd526dfc82542b67b9ceb15e21c34f94cfcc0d91
parent69f1936c6700403fb94920f44346a5e2a66e2f86
expmed: Fix store_integral_bit_field [PR101562]

Our documentation says that paradoxical subregs shouldn't appear
in strict_low_part:
'(strict_low_part (subreg:M (reg:N R) 0))'
     This expression code is used in only one context: as the
     destination operand of a 'set' expression.  In addition, the
     operand of this expression must be a non-paradoxical 'subreg'
     expression.
but on the testcase below that triggers UB at runtime
store_integral_bit_field emits exactly that.

The following patch fixes it by ensuring the requirement is satisfied.

2021-07-23  Jakub Jelinek  <jakub@redhat.com>

PR rtl-optimization/101562
* expmed.c (store_integral_bit_field): Only use movstrict_optab
if the operand isn't paradoxical.

* gcc.c-torture/compile/pr101562.c: New test.

(cherry picked from commit 8408d34570c9fe9f3d22a25a76df2a4c64f08477)
gcc/expmed.c
gcc/testsuite/gcc.c-torture/compile/pr101562.c [new file with mode: 0644]
This page took 0.060654 seconds and 6 git commands to generate.