https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69454
--- Comment #13 from Ilya Enkovich <ienkovich at gcc dot gnu.org> --- (In reply to Jakub Jelinek from comment #5) > Already during the expansion TARGET_STV makes quite a big difference, won't > just disabling the stv pass cause performance regression to -mno-stv? There is a difference on how code is expanded but we didn't observe significant code regressions because of it so far. > Also, I'm surprised you are checking INCOMING_STACK_BOUNDARY, I'd have > expected > || ix86_preferred_stack_boundary >= 128 > instead. I check INCOMING_STACK_BOUNDARY because that's what expand_stack_alignment checks to determine if realignment and DRAP register are needed. > > I had in mind either: > > --- gcc/config/i386/i386.c.jj 2016-01-25 12:10:57.000000000 +0100 > +++ gcc/config/i386/i386.c 2016-01-25 16:54:28.662713284 +0100 > @@ -5453,6 +5453,11 @@ ix86_option_override_internal (bool main > opts->x_target_flags |= MASK_VZEROUPPER; > if (!(opts_set->x_target_flags & MASK_STV)) > opts->x_target_flags |= MASK_STV; > + /* Disable STV if -mpreferred-stack-boundary={2,3} - the needed > + stack realignment will be extra cost the pass doesn't take into > + account and the pass does not ensure DRAP is created either. */ > + if (ix86_preferred_stack_boundary < 128) > + opts->x_target_flags &= ~MASK_STV; > if (!ix86_tune_features[X86_TUNE_AVX256_UNALIGNED_LOAD_OPTIMAL] > && !(opts_set->x_target_flags & MASK_AVX256_SPLIT_UNALIGNED_LOAD)) > opts->x_target_flags |= MASK_AVX256_SPLIT_UNALIGNED_LOAD; > > (i.e. force -mno-stv for -mpreferred-boundary={2,3}), but that will likely > disable the pass altogether for the -miamcu (but your patch in most cases > will too), not sure if that is a big deal or not). IAMCU doesn't have SSE, thus it's not an issue. But here we disable STV even if we are going to align stack anyway (e.g. have vector code). > Another alternative is if the STV pass changes anything and creates possible > need for aligned vector spills, create drap rtx during that pass. I like this option, but I wonder if it's safe to do that at STV pass. expand_stack_alignment calls fixup_tail_calls and invalidates some notes if DRAP is allocated. Can it be too late to do that in STV?