On Thu, 19 May 2022, Jakub Jelinek wrote: > On Fri, May 13, 2022 at 12:23:01PM +0200, Richard Biener wrote: > > 2022-05-13 Richard Biener <rguent...@suse.de> > > > > * omp-expand.cc (expand_omp_atomic_cas): Do not short-cut > > computation of the new value. > > Ok, thanks. > > Though, depending on what exactly you allow or disallow, maybe even > the im != 0 might not be acceptable. > Oh, and if COND_EXPRs can only use some limited set of comparisons, we might > need to adjust e.g. arith_overflow_check_p and various other spots in > tree-ssa-math-opts.cc and other passes.
With the changes I have in the queue the !cond_stmt path should be effectively dead code (though I don't remove such immediately). Not sure what you think the issue with arith_overflow_check_p would be? Note this is only about COND_EXPRs in gimple assignments. I'm going to push this OMP patch later but will delay pushing the COND_EXPR patches until next week so I'm around more reliably to deal with fallout. Richard. > > diff --git a/gcc/omp-expand.cc b/gcc/omp-expand.cc > > index ee708314793..9fcc67a3448 100644 > > --- a/gcc/omp-expand.cc > > +++ b/gcc/omp-expand.cc > > @@ -9092,16 +9092,17 @@ expand_omp_atomic_cas (basic_block load_bb, tree > > addr, > > > > if (cond_stmt) > > { > > - g = gimple_build_assign (gimple_assign_lhs (cond_stmt), > > - NOP_EXPR, im); > > + g = gimple_build_assign (cond, NOP_EXPR, im); > > gimple_set_location (g, loc); > > gsi_insert_before (&gsi, g, GSI_SAME_STMT); > > } > > - else if (need_new) > > + > > + if (need_new) > > { > > g = gimple_build_assign (create_tmp_reg (itype), COND_EXPR, > > - build2 (NE_EXPR, boolean_type_node, > > - im, build_zero_cst (itype)), > > + cond_stmt > > + ? cond : build2 (NE_EXPR, boolean_type_node, > > + im, build_zero_cst (itype)), > > d, re); > > gimple_set_location (g, loc); > > gsi_insert_before (&gsi, g, GSI_SAME_STMT); > > -- > > 2.35.3 > > Jakub > > -- Richard Biener <rguent...@suse.de> SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany; GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman; HRB 36809 (AG Nuernberg)