middle-end/106331 - fix mem attributes for string op arguments
authorRichard Biener <rguenther@suse.de>
Tue, 19 Jul 2022 07:57:22 +0000 (09:57 +0200)
committerRichard Biener <rguenther@suse.de>
Tue, 19 Jul 2022 09:27:22 +0000 (11:27 +0200)
commit1a7200da71550e6f92da66f0b328bb20d3bcdf35
treeb829d769f55319a05e0feaea99c9f433742b8bdc
parentec9287ba9718871aa64900d6168105802e1ca941
middle-end/106331 - fix mem attributes for string op arguments

get_memory_rtx tries hard to come up with a MEM_EXPR to record
in the memory attributes but in the last fallback fails to properly
account for an unknown offset and thus, as visible in this testcase,
incorrect alignment computed from set_mem_attributes.  The following
rectifies both parts.

PR middle-end/106331
* builtins.cc (get_memory_rtx): Compute alignment from
the original address and set MEM_OFFSET to unknown when
we create a MEM_EXPR from the base object of the address.

* gfortran.dg/pr106331.f90: New testcase.

(cherry picked from commit e4ff11a8f2e80adb8ada69bf35ee6a1ab18a9c85)
gcc/builtins.cc
gcc/testsuite/gfortran.dg/pr106331.f90 [new file with mode: 0644]