From: Richard Biener Date: Fri, 17 Feb 2023 11:36:44 +0000 (+0100) Subject: tree-optimization/108821 - store motion and volatiles X-Git-Tag: basepoints/gcc-14~1093 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4c4f0f7acd6b96ee744ef598cbea5c7046a33654;p=thirdparty%2Fgcc.git tree-optimization/108821 - store motion and volatiles The following fixes store motion to not re-issue volatile stores to preserve TBAA behavior since that will result in the number of volatile accesses changing. PR tree-optimization/108821 * tree-ssa-loop-im.cc (sm_seq_valid_bb): We can also not move volatile accesses. * gcc.dg/tree-ssa/ssa-lim-24.c: New testcase. --- diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-lim-24.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-lim-24.c new file mode 100644 index 000000000000..6b463490a912 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-lim-24.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-lim2-details -fdump-tree-optimized" } */ + +extern volatile int *x; +static int gCrc; + +static int __attribute__((noinline)) crc16Add(int crc, int b) +{ + return crc + b; +} + +void f(int data, int dataSz) +{ + int i; + + for(i=0;iref == UNANALYZABLE_MEM_ID) return -1; /* Stop at memory references which we can't move. */ - else if (memory_accesses.refs_list[data->ref]->mem.ref == error_mark_node) + else if (memory_accesses.refs_list[data->ref]->mem.ref == error_mark_node + || TREE_THIS_VOLATILE + (memory_accesses.refs_list[data->ref]->mem.ref)) { /* Mark refs_not_in_seq as unsupported. */ bitmap_ior_into (refs_not_supported, refs_not_in_seq);