Bug 14736 - [tree-ssa] code quality regression
Summary: [tree-ssa] code quality regression
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: tree-ssa
: P2 normal
Target Milestone: 4.0.0
Assignee: Andrew Pinski
URL:
Keywords: compile-time-hog, memory-hog, missed-optimization
Depends on:
Blocks:
 
Reported: 2004-03-25 23:19 UTC by Dan Nicolaescu
Modified: 2004-06-02 19:58 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2004-03-25 23:34:57


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dan Nicolaescu 2004-03-25 23:20:00 UTC
There seems to be a code quality regression in tree-ssa between 
2004/03/08 and 2004/03/20 

The .vars dump for generate-3.4.ii from PR8361 generated by 
gcc version 3.5-tree-ssa 20040308 (merged 20040305)
has 100840 lines
the one generated by
gcc version 3.5-tree-ssa 20040320 (merged 20040307)
has 85811 lines.

Granted the number of lines in .vars is not the best measure of code
quality, but given the 15% size difference something seems wrong. 

Looking at the diff between the 2 I saw the following type of
difference in a few places:

 <L5>:;
-  if (__result == __first) goto <L6>; else goto <L7>;
+  se = (struct ELEMENT &)__first;
+  if (__result == (struct ELEMENT * const)se) goto <L6>; else goto <L7>; 


Given that this code is from std::vector::iterator it appears in quite a
few places. Look for example at:
typename std::vector<_Tp, _Alloc>::iterator std::vector<_Tp,
_Alloc>::erase(__gnu_cxx::__normal_iterator<_Tp*, std::vector<_Tp, _Alloc> >,
__gnu_cxx::__normal_iterator<_Tp*, std::vector<_Tp, _Alloc> >) [with _Tp =
STACK<int>::ELEMENT, _Alloc = std::allocator<STACK<int>::ELEMENT>] (this,
__first, __last)



Another oddity is code like:

<L38>:;
  __first = __first;
  __result = __result;
Comment 1 Andrew Pinski 2004-03-25 23:34:57 UTC
Assigning to Diego.
Comment 2 Andrew Pinski 2004-04-06 19:14:46 UTC
I think this is better now but I might be looking into the wrong .vars the one with my cast 
pass included.
Comment 3 Andrew Pinski 2004-05-16 01:25:32 UTC
I think these regressions come from the movement away from convert to fold_convert in 
the middle-end.  I think I have a fix which also gets rid of most of the usefulness of my 
cast pass.
Comment 4 Andrew Pinski 2004-05-17 00:01:24 UTC
And no my patch did not fix this part but another some more work in fold_convert can 
help.
Comment 5 Andrew Pinski 2004-06-02 04:32:31 UTC
Mine caused by Dale's patch to use the language hooks.  I have a patch.
Comment 6 Andrew Pinski 2004-06-02 04:33:14 UTC
Here is the patch:
Index: tree-ssa.c
===============================================================
====
RCS file: /cvs/gcc/gcc/gcc/tree-ssa.c,v
retrieving revision 2.3
diff -u -p -r2.3 tree-ssa.c
--- tree-ssa.c	14 May 2004 02:29:23 -0000	2.3
+++ tree-ssa.c	2 Jun 2004 04:32:50 -0000
@@ -555,7 +555,8 @@ tree_ssa_useless_type_conversion_1 (tree
      so strip conversions that just switch between them.  */
   else if (POINTER_TYPE_P (inner_type)
            && POINTER_TYPE_P (outer_type)
-           && lang_hooks.types_compatible_p (inner_type, outer_type))
+           && lang_hooks.types_compatible_p (TREE_TYPE (inner_type),
+					     TREE_TYPE (outer_type)))
     return true;
 
   /* If both the inner and outer types are integral types, then the
Comment 7 Andrew Pinski 2004-06-02 04:41:14 UTC
Much newer and simpler patch: <http://gcc.gnu.org/ml/gcc-patches/2004-06/msg00087.html>.
Comment 8 Dan Nicolaescu 2004-06-02 17:38:25 UTC
(In reply to comment #7)
> Much newer and simpler patch:
<http://gcc.gnu.org/ml/gcc-patches/2004-06/msg00087.html>.

Great! Thanks for taking care of this!
Could you also post some before and after numbers? They should be very interesting. 
Like the number of lines in the dump files, or the number of temp variables
created. 
Comment 10 Andrew Pinski 2004-06-02 19:00:44 UTC
Dann, sorry I did not do any timings or any other numbers because I was to lazy to do any and I 
wantted to get this in and fixed.
Comment 11 Andrew Pinski 2004-06-02 19:58:14 UTC
Fixed.