[Bug target/86386] [8/9 Regression] unaligned load from stack with -Os -fno-tree-dce -mstringop-strategy=vector_loop -mavx512bw
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86386 H.J. Lu changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |FIXED --- Comment #9 from H.J. Lu --- Fixed for GCC 9 and 8.3.
[Bug target/86386] [8/9 Regression] unaligned load from stack with -Os -fno-tree-dce -mstringop-strategy=vector_loop -mavx512bw
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86386 --- Comment #8 from hjl at gcc dot gnu.org --- Author: hjl Date: Tue Aug 7 15:06:01 2018 New Revision: 263359 URL: https://gcc.gnu.org/viewcvs?rev=263359=gcc=rev Log: i386: Set cfun->machine->max_used_stack_alignment if needed cfun->machine->max_used_stack_alignment is used to decide how stack frame should be aligned. This is independent of any psABIs nor 32-bit vs 64-bit. It is always safe to compute max_used_stack_alignment. We compute it only if 128-bit aligned load/store may be generated on misaligned stack slot which will lead to segfault. gcc/ Backport from mainline PR target/86386 * config/i386/i386.c (ix86_finalize_stack_frame_flags): Set cfun->machine->max_used_stack_alignment if needed. gcc/testsuite/ Backport from mainline PR target/86386 * gcc.target/i386/pr86386.c: New file. Added: branches/gcc-8-branch/gcc/testsuite/gcc.target/i386/pr86386.c Modified: branches/gcc-8-branch/gcc/ChangeLog branches/gcc-8-branch/gcc/config/i386/i386.c branches/gcc-8-branch/gcc/testsuite/ChangeLog
[Bug target/86386] [8/9 Regression] unaligned load from stack with -Os -fno-tree-dce -mstringop-strategy=vector_loop -mavx512bw
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86386 --- Comment #7 from hjl at gcc dot gnu.org --- Author: hjl Date: Sun Aug 5 12:46:13 2018 New Revision: 263317 URL: https://gcc.gnu.org/viewcvs?rev=263317=gcc=rev Log: i386: Set cfun->machine->max_used_stack_alignment if needed cfun->machine->max_used_stack_alignment is used to decide how stack frame should be aligned. This is independent of any psABIs nor 32-bit vs 64-bit. It is always safe to compute max_used_stack_alignment. We compute it only if 128-bit aligned load/store may be generated on misaligned stack slot which will lead to segfault. gcc/ PR target/86386 * config/i386/i386.c (ix86_finalize_stack_frame_flags): Set cfun->machine->max_used_stack_alignment if needed. gcc/testsuite/ PR target/86386 * gcc.target/i386/pr86386.c: New file. Added: trunk/gcc/testsuite/gcc.target/i386/pr86386.c Modified: trunk/gcc/ChangeLog trunk/gcc/config/i386/i386.c trunk/gcc/testsuite/ChangeLog
[Bug target/86386] [8/9 Regression] unaligned load from stack with -Os -fno-tree-dce -mstringop-strategy=vector_loop -mavx512bw
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86386 --- Comment #6 from H.J. Lu --- I am testing this patch diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index ee409cfe7e4..9971b369f45 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -13281,8 +13281,7 @@ ix86_finalize_stack_frame_flags (void) recompute_frame_layout_p = true; } } - else if (crtl->max_used_stack_slot_alignment - > crtl->preferred_stack_boundary) + else if (crtl->max_used_stack_slot_alignment) { /* We don't need to realign stack. But we still need to keep stack frame properly aligned to satisfy the largest alignment
[Bug target/86386] [8/9 Regression] unaligned load from stack with -Os -fno-tree-dce -mstringop-strategy=vector_loop -mavx512bw
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86386 Jakub Jelinek changed: What|Removed |Added Target Milestone|8.2 |8.3 --- Comment #5 from Jakub Jelinek --- GCC 8.2 has been released.
[Bug target/86386] [8/9 Regression] unaligned load from stack with -Os -fno-tree-dce -mstringop-strategy=vector_loop -mavx512bw
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86386 --- Comment #4 from Jakub Jelinek --- The A128 MEM is introduced during RA, *.ira still has: (insn 26 24 28 2 (set (mem/c:QI (reg/f:DI 16 argp) [0 MEM[(char * {ref-all})]+0 S1 A32]) (vec_select:QI (subreg:V16QI (reg:TI 88 [ _2 ]) 0) (parallel [ (const_int 2 [0x2]) ]))) "pr86386.c":9 3728 {*vec_extractv16qi} (nil)) and *.reload replaces it with: (insn 151 23 24 2 (set (mem/c:TI (plus:DI (reg/f:DI 7 sp) (const_int -16 [0xfff0])) [3 %sfp+-16 S16 A128]) (reg:TI 0 ax [orig:88 _2 ] [88])) "pr86386.c":8 84 {*movti_internal} (nil)) ... (insn 152 24 26 2 (set (reg:V16QI 21 xmm0 [168]) (mem/c:V16QI (plus:DI (reg/f:DI 7 sp) (const_int -16 [0xfff0])) [3 %sfp+-16 S16 A128])) "pr86386.c":9 1283 {movv16qi_internal} (nil)) (insn 26 152 28 2 (set (mem/c:QI (plus:DI (reg/f:DI 6 bp) (const_int 16 [0x10])) [0 MEM[(char * {ref-all})]+0 S1 A32]) (vec_select:QI (reg:V16QI 21 xmm0 [168]) (parallel [ (const_int 2 [0x2]) ]))) "pr86386.c":9 3728 {*vec_extractv16qi} (nil))
[Bug target/86386] [8/9 Regression] unaligned load from stack with -Os -fno-tree-dce -mstringop-strategy=vector_loop -mavx512bw
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86386 Jakub Jelinek changed: What|Removed |Added CC||jakub at gcc dot gnu.org --- Comment #3 from Jakub Jelinek --- Started with r250084. /* PR target/86386 */ /* { dg-do run { target { avx_runtime && int128 } } } */ /* { dg-options "-Os -fno-tree-dce -mstringop-strategy=vector_loop -mavx" } */ unsigned c, d, e, f; unsigned __attribute__((noipa)) foo (unsigned char g, unsigned short h, unsigned i, unsigned long long j, unsigned char k, unsigned short l, unsigned m, unsigned __int128 n) { __builtin_memset (, 0, 3); n <<= m; __builtin_memcpy (, 2 + (char *) , 1); m >>= 0; d ^= __builtin_mul_overflow (l, n, ); return m; } int main () { unsigned __int128 x = foo (0, 0, 0, 0, 0, 4, 1, 3); if (x != 24) __builtin_abort (); return 0; }
[Bug target/86386] [8/9 Regression] unaligned load from stack with -Os -fno-tree-dce -mstringop-strategy=vector_loop -mavx512bw
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86386 H.J. Lu changed: What|Removed |Added CC||hjl.tools at gmail dot com --- Comment #2 from H.J. Lu --- There is: (insn 152 173 157 2 (set (reg:V16QI 21 xmm0 [168]) (mem/c:V16QI (plus:DI (reg/f:DI 7 sp) (const_int -16 [0xfff0])) [3 %sfp+-16 S16 A128])) "x.i":14 1283 {movv16qi_internal} (nil)) A128 seems incorrect.
[Bug target/86386] [8/9 Regression] unaligned load from stack with -Os -fno-tree-dce -mstringop-strategy=vector_loop -mavx512bw
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86386 Richard Biener changed: What|Removed |Added Priority|P3 |P2 Status|UNCONFIRMED |NEW Last reconfirmed||2018-07-03 Target Milestone|--- |8.2 Ever confirmed|0 |1 --- Comment #1 from Richard Biener --- Confirmed. Looks like the stack is not aligned for some odd reason. Doesn't need AVX512 at runtime btw, just the flag somehow triggers it... -mavx is enough btw.