forwprop: Fix copy prop for alignment after the final folding [PR122086]
After
r16-4081-g966cdec2b2 which added folding of __builtin_assume_aligned,
forwprop would propagate pointers that lower alignment replacing ones with
greater alignment. This causes us to lose alignment information that
__builtin_assume_aligned provided to expand. Normally this just loses some
optimizations except in the s390 case where the alignment is specifically
checked and was for inlining of the atomics; without this patch an infininite
loop would happen.
Note this was previously broken for -Og before
r16-4081-g966cdec2b2. This
fixes -Og case as forwprop is used instead of copyprop.
This moves the testcase for pr107389.c to torture to get a generic testcase.
pr107389.c was originally for -O0 case but we should test for other
optimization levels so this is not lost again.
align-5.c is xfailed because __builtin_assume_aligned is not instrumented for ubsan
alignment and ubsan check to see pointer is aligned before emitting a check for the
load (based on the known alignment in compiling). See PR 122038 too. I had mentioned
this issue previously in
r16-4081-g966cdec2b2 too.
PR middle-end/107389
PR tree-optimization/122086
gcc/ChangeLog:
* tree-ssa-forwprop.cc (forwprop_may_propagate_copy): New function.
(pass_forwprop::execute): Use forwprop_may_propagate_copy
instead of may_propagate_copy.
gcc/testsuite/ChangeLog:
* gcc.dg/pr107389.c: Move to...
* gcc.dg/torture/pr107389.c: ...here. Skip for lto.
Use dg-additional-options rather than dg-options.
* c-c++-common/ubsan/align-5.c: xfail.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>