This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix tree-opt/21840, FRE/PRE mismatch types inMODIFY_EXPR
- From: Daniel Berlin <dberlin at dberlin dot org>
- To: Andrew Pinski <pinskia at physics dot uc dot edu>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 12 Jul 2005 21:58:47 -0400
- Subject: Re: [PATCH] Fix tree-opt/21840, FRE/PRE mismatch types inMODIFY_EXPR
- References: <49836e5e2d1f42563d6c67dde45a1e2d@physics.uc.edu>
On Tue, 2005-07-12 at 21:36 -0400, Andrew Pinski wrote:
> The problem here is that PRE/FRE forgets to add a cast if we going from
> a void* to another type (like a function pointer). Since x86 requires
> the correct function type to be able to call the function, the cast is
> really needed. This is caught even without my patch attached in PR
> 22368.
>
> This patch fixes the type mismatch by converting the type to the correct
> type. The reason why this is safe is because we always get back either
> a SSA_NAME or a constant and we can cast that expression and still be
> valid gimple as we are always replacing the rhs of a MODIFY_EXPR.
>
> OK? Bootstrapped and tested on powerpc-darwin with no regressions.
>
This is fine. Could you please add a small comment above the code
you've added saying something like
"We need to make sure the new and old types actually match, which may
require adding a simple cast, which fold_convert will do for us"
(or whatever)
>
> Thanks,
> Andrew Pinski
>
> ChangeLog:
>
> * tree-ssa-pre.c (eliminate): Convert the sprime to the correct type
> if *rhs_p is not a SSA_NAME.
>
> testsuite/ChangeLog:
>
> * gcc.c-torture/compile/pr21840.c: New test.
>