On Mon, Nov 07, 2022 at 10:02:11AM +0100, Richard Biener wrote: > The following adds a fold_builtins pass at -O0, keying off some > unwanted optimization and setting pointer alignment of the result > of __builtin_assume_alignment before removing the call. This > allows libatomic calls to be elided at -O0 on s390 for > > __uint128_t foo(__uint128_t *p) > { > return __atomic_load_n((__uint128_t *)__builtin_assume_aligned (p, 16), 0); > } > > not sure how to reliably test this though. > > Thoughts?
Do we really need a separate pass for it? Can't we do it say during gimplification? > PR tree-optimization/107389 > * tree-pass.h (pass_fold_builtins_O0): Declare. > * passes.def (pass_fold_builtins_O0): Schedule. > * tree-ssa-ccp.cc (pass_fold_builtins_O0): Define. > (pass_fold_builtins): Template, add gate. > (pass_fold_builtins::execute): Apply alignment to the > target of __builtin_assume_aligned at -O0. Disable most > optimizations for the -O0 pass instance. Jakub