Live data from Hacker News

54-line if condition in gcc's reload.c

github.com

41–50 of 95 posts

Re: 54-line if condition in gcc's reload.c

#41
For the curious, reload was written by Richard Kenner, who, while a wonderful guy, was not generally familiar with modern compiler architecture (graph coloring register allocation goes back to 1982, reload was started in the late 80's).

It essentially took the place of spill placement/code/legalization. Over the years, it grew rematerialization, instruction combination, copy coalescing, stack slot sharing and all sorts of other interesting scope creep.

While i believe it has finally been replaced by LRA for some targets, there were many people who spent years of their life trying to replace reload with separate, smaller pieces of architecture. No one has yet completely succeeded.

It is essentially an interesting object lesson in what happens when you just incrementally improve architecture to achieve performance goals without a stop-loss point for requiring new design.

Re: 54-line if condition in gcc's reload.c

#42
post #28

Earlier quoted context omitted.

I'm impressed that the blame log has survived intact. What SCM was originally used?

Probably RCS http://www.gnu.org/software/rcs/ ; It's a fact that it used CVS, then SVN at some point (see https://gcc.gnu.org/viewcvs/gcc/branches/CYGNUS/ , a branch created by cvs2svn, a migration tool) EDIT: Apparently all previous history was lost when they implemented CVS, circa 1997. We could always ask someone in the oldest maintainers file available ( https://gcc.gnu.org/viewcvs/gcc/trunk/MAINTAINERS?revision=…

Your last part is not correct. We had the "old-gcc" RCS files, it just was in a format not parseable by CVS. It was not entirely lost, just not easily accessible. Ian Taylor went to the trouble of rewriting the RCS files CVS had, and that we based the SVN repository on, to include the old data, so actually, SVN had more history than the CVS versions, dating back to 1987.

Re: 54-line if condition in gcc's reload.c

#43

Why put logical operator at the start and not the end of each line? I.e., this style (used in this case) && (CONSTANT_P (SUBREG_REG (in)) || GET_CODE (SUBREG_REG (in)) == PLUS || strict_low || (((REG_P (SUBREG_REG (in)) versus this style: (CONSTANT_P (SUBREG_REG (in)) || GET_CODE (SUBREG_REG (in)) == PLUS || strict_low || (((REG_P (SUBREG_REG (in)) && I don't have a personal preference here, just looking for any prac…

I prefer the operators at the start because the start is less jagged, so the operators don't get spread out so much and stand out more. Usually I only put them at the end of a line in languages that do implicit line endings, and will false-positive when you move the operator to the next line (i.e. javascript and visual basic).

Javascripr lets you put the binary operators in the next line if you want. It won't insert a semicolon there:

http://blog.izs.me/post/2353458699/an-open-letter-to-javascr...

I would say that the most common problem is having a semicolon not being inserted if you start a line with `(` or `[`. In practice, the only time when a semicolon gets inserted where it shouldn't is when returning an object literal.

Re: 54-line if condition in gcc's reload.c

#46
post #10

Earlier quoted context omitted.

It's been getting the job done for decades, in perhaps the most popular compiler of all time. I'm willing to trust the maintainers' judgement on this one. If they'd spent all their time needlessly fixing what ain't broke, gcc would've gone the way of GNU/Hurd.

> It's been getting the job done for decades, in perhaps the most popular compiler of all time. I'm willing to trust the maintainers' judgement on this one. I don't trust anyone - myself included - writing code 1/10th as convoluted, age-of-product be damned. Code is not wine, old doesn't mean good. Neither do the maintainers, methinks: Looking at blame shows some refactoring. > If they'd spent all their time needless…

Old code is better - it's got bug fixes.

Re: 54-line if condition in gcc's reload.c

#47

Earlier quoted context omitted.

I'm impressed that the blame log has survived intact. What SCM was originally used?

So, i converted the repository to SVN (which is what this is based on). Originally? None. Then RCS Then it forked into EGCS and GCC, and EGCS used CVS On remerge, we used CVS. Then we converted to SVN. I basically rewrote large parts of cvs2svn to make this happen (before that it took weeks to convert and ran out of memory anyway :P) During cvs2svn conversion, the old GCC RCS versions we had data for were inserted as…

> Originally? None.

Although note that a lot of earlyish GNU codebases kept tons of older versions of source files around in the form of Emacs versioned backup files, and there were RCS-conversion scripts that would commit all of those as RCS versions...

[There would be no log messages for those older versions, of course, but the writers and creation dates of the older files were potentially available... I don't really remember whether those conversion scripts actually used that info or not, although I think they did...]

Re: 54-line if condition in gcc's reload.c

#48
post #5
post #2

Trivia: This code is older than many of the readers. https://github.com/mirrors/gcc/blame/7057506456ba18f080679b2...

This code is one month younger than me.

Since it's trivia we're dealing with. This commit was made 18 days before I was born: https://github.com/mirrors/gcc/commit/cbbca02e2430b2dc1f5681... :)

Re: 54-line if condition in gcc's reload.c

#49
post #10
post #4

Why not break it up into variables or functions so that the logic can be followed while reducing the likelihood that a bug creeps in? What is the excuse for horrible code like this?

It's been getting the job done for decades, in perhaps the most popular compiler of all time. I'm willing to trust the maintainers' judgement on this one. If they'd spent all their time needlessly fixing what ain't broke, gcc would've gone the way of GNU/Hurd.

The problem of course, is that although reload very typically would work pretty well for the existing supported architectures (and optimizations etc), porting to a new architecture or changing other algorithms in the compiler would often expose problems that required extremely painful tweaking of the mess of unstated assumptions in the giant code hairball that is (was) reload... >LRA is by all appearances infinitely more maintainable.

Re: 54-line if condition in gcc's reload.c

#50
post #23

Earlier quoted context omitted.

I'm impressed that the blame log has survived intact. What SCM was originally used?

Probably Git? You know that's been around much longer than Github has, right.

Of course, but even without checking Wikipedia, I remember a time not too terribly long ago when git, and even svn, didn't exist.
Post reply on HN