This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C PATCH] Preevaluate rhs for lhs op= rhs in C (PR c/58943)
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: "Joseph S. Myers" <joseph at codesourcery dot com>, Richard Biener <rguenther at suse dot de>, "Balaji V. Iyer" <balaji dot v dot iyer at intel dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 15 Jan 2014 05:33:52 -0800
- Subject: Re: [C PATCH] Preevaluate rhs for lhs op= rhs in C (PR c/58943)
- Authentication-results: sourceware.org; auth=none
- References: <20140113191133 dot GC892 at tucnak dot redhat dot com>
On Mon, Jan 13, 2014 at 11:11 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> This patch fixes the following testcase by preevaluating rhs if it has
> (can have) side-effects in lhs op= rhs expressions. Bootstrapped/regtested
> on x86_64-linux and i686-linux, ok for trunk?
> C++ already does a similar thing (though in that case with TARGET_EXPRs).
>
> Note1: had to tweak ssa-fre-33.c testcase a little bit (but it still fails
> without the fix which went together with it and succeeds with the fix
> and from that point onwards), because before fre1 there isn't enough forward
> propagation that would make it constant (the addition result becomes
> constant during fre1).
>
> Note2: c-c++-common/cilk-plus/AN/rank_mismatch2.c ICEs now, supposedly
> array notation handling doesn't handle SAVE_EXPRs properly, Balaji, do you
> think you can debug it and fix up afterwards?
>
> 2014-01-13 Jakub Jelinek <jakub@redhat.com>
>
> PR c/58943
> * c-typeck.c (build_modify_expr): For lhs op= rhs, if rhs has side
> effects, preevaluate rhs using SAVE_EXPR first.
>
> * c-omp.c (c_finish_omp_atomic): Set in_late_binary_op around
> build_modify_expr with non-NOP_EXPR opcode. Handle return from it
> being COMPOUND_EXPR.
> (c_finish_omp_for): Handle incr being COMPOUND_EXPR with first
> operand a SAVE_EXPR and second MODIFY_EXPR.
>
This caused:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59825
--
H.J.