This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C PATCH] Fix C pointer_diff with volatile args (PR c/86093)
- From: Joseph Myers <joseph at codesourcery dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Marek Polacek <polacek at redhat dot com>, <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 15 Jun 2018 20:52:01 +0000
- Subject: Re: [C PATCH] Fix C pointer_diff with volatile args (PR c/86093)
- References: <20180615191221.GG7166@tucnak>
On Fri, 15 Jun 2018, Jakub Jelinek wrote:
> Hi!
>
> The match.pd framework uses op0 == op1 || operand_equal_p (op0, op1, 0)
> style comparisons heavily; the reason why we don't optimize away say
> volatile int i;
> ...
> int j = i - i;
> into int j = (i, 0);
> is only because both the C and C++ FE convert the volatile arguments to
> non-volatile ones before the arithmetic operation (e.g. c_common_type
> returns a non-qualified type). Unfortunately, in C FE this doesn't happen
> for POINTER_DIFF_EXPR, where no conversion happens. The following patch
> makes sure we convert the pointer arguments to some non-qualified pointers
> first.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk/8.2?
OK.
--
Joseph S. Myers
joseph@codesourcery.com