| Summary: | [8/9 Regression] store-merging wrong-code | ||
|---|---|---|---|
| Product: | gcc | Reporter: | Jakub Jelinek <jakub> |
| Component: | tree-optimization | Assignee: | Jakub Jelinek <jakub> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | ||
| Priority: | P3 | ||
| Version: | 9.0 | ||
| Target Milestone: | 8.2 | ||
| Host: | Target: | ||
| Build: | Known to work: | ||
| Known to fail: | Last reconfirmed: | 2018-07-11 00:00:00 | |
| Attachments: | gcc9-pr86492.patch | ||
Created attachment 44385 [details] gcc9-pr86492.patch Untested fix. Author: jakub Date: Thu Jul 12 07:39:33 2018 New Revision: 262576 URL: https://gcc.gnu.org/viewcvs?rev=262576&root=gcc&view=rev Log: PR tree-optimization/86492 * gimple-ssa-store-merging.c (imm_store_chain_info::coalesce_immediate_stores): Call check_no_overlap even for the merge_overlapping case. Formatting fix. * gcc.c-torture/execute/pr86492.c: New test. Added: trunk/gcc/testsuite/gcc.c-torture/execute/pr86492.c Modified: trunk/gcc/ChangeLog trunk/gcc/gimple-ssa-store-merging.c trunk/gcc/testsuite/ChangeLog Author: jakub Date: Thu Jul 12 07:46:04 2018 New Revision: 262577 URL: https://gcc.gnu.org/viewcvs?rev=262577&root=gcc&view=rev Log: PR tree-optimization/86492 * gimple-ssa-store-merging.c (imm_store_chain_info::coalesce_immediate_stores): Call check_no_overlap even for the merge_overlapping case. * gcc.c-torture/execute/pr86492.c: New test. Added: branches/gcc-8-branch/gcc/testsuite/gcc.c-torture/execute/pr86492.c Modified: branches/gcc-8-branch/gcc/ChangeLog branches/gcc-8-branch/gcc/gimple-ssa-store-merging.c branches/gcc-8-branch/gcc/testsuite/ChangeLog Fixed for 8.2+. Thank you Jakub for the quick fix and as stated the patch works for reported case. |
union U { unsigned int r; struct { unsigned int a:12; unsigned int b:4; unsigned int c:16; } f; }; __attribute__((noinline, noclone)) unsigned int foo (unsigned int x) { union U r; r.r = 0; r.f.c = x; r.f.b = 0xe; return r.r; } int main () { volatile unsigned int x; x = 0x72; x = foo (x); union U r; r.r = x; if (r.f.a != 0 || r.f.b != 0xe || r.f.c != 0x72) __builtin_abort (); return 0; } is miscompiled by store-merging at -O2.