Live data from Hacker News

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

github.com

1–10 of 95 posts

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

#7
post #2

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

That's beautiful. It may be a monster, but it started so small in 1992 - then was grown with loving care in 1993, 1994, 1995, 1998, 1999, 2001, 2002, 2004, 2005, 2008, and 2011!

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

#8

No wonder llvm is getting popular (I realize that there are other reasons besides codebase quality).

Compilers are complex, and these conditionals had to be evaluated in some way. Sure the author could have split it up into multiple if statements, but would have that really helped?

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

#9
post #8

No wonder llvm is getting popular (I realize that there are other reasons besides codebase quality).

Compilers are complex, and these conditionals had to be evaluated in some way. Sure the author could have split it up into multiple if statements, but would have that really helped?

Yes, yes it would have, there is literally no question about that. It also appears that some of the parts of the conditions are repeated, so those could have been refactored.

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

#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.

Post reply on HN