This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[tree-ssa] Convert fold's result
- From: law at redhat dot com
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 17 Sep 2003 21:22:02 -0600
- Subject: [tree-ssa] Convert fold's result
- Reply-to: law at redhat dot com
This fixes 20030917-3.c. In a nutshell, we're missing optimization
opportunities because the RHS type is a integer type and the RESULT
type is boolean. Converting the result to the RHS's type makes everything
happy.
* tree-ssa-ccp.c (ccp_fold): If the return value has the wrong
type, try to convert it to the proper type rather than failing.
Index: tree-ssa-ccp.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-ccp.c,v
retrieving revision 1.1.2.90
diff -c -3 -p -r1.1.2.90 tree-ssa-ccp.c
*** tree-ssa-ccp.c 16 Sep 2003 23:46:38 -0000 1.1.2.90
--- tree-ssa-ccp.c 18 Sep 2003 03:19:55 -0000
*************** ccp_fold (tree stmt)
*** 841,850 ****
else
return rhs;
! /* If we got a simplified form and the type of the simplified form
! is the same type as the original, then return the simplified form. */
! if (retval && TREE_TYPE (retval) == TREE_TYPE (rhs))
! return retval;
/* No simplification was possible. */
return rhs;
--- 841,855 ----
else
return rhs;
! /* If we got a simplified form, see if we need to convert its type. */
! if (retval)
! {
! if (TREE_TYPE (retval) != TREE_TYPE (rhs))
! retval = convert (TREE_TYPE (rhs), retval);
!
! if (TREE_TYPE (retval) == TREE_TYPE (rhs))
! return retval;
! }
/* No simplification was possible. */
return rhs;