I'm more concerned with the fact that the function is more than 700 lines long.
54-line if condition in gcc's reload.c
51–60 of 95 posts
Re: 54-line if condition in gcc's reload.c
#52Earlier 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…
Edit: also reading the wiki, they are fully aware how bad this code is.
Re: 54-line if condition in gcc's reload.c
#53Earlier quoted context omitted.
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
#54Re: 54-line if condition in gcc's reload.c
#55Why 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 used to use the latter, in both code and maths, but I have switched to the former. My main reason is that having the operators (logical and otherwise) at the start of the line means they're more likely to be in the same horizontal position, so it's easier to see which lines are continuations of the previous ones.
SELECT
some_col
, another_col
--, and_another
, and_more
FROM blah
EDIT: too bad formatting is screwed up :/Re: 54-line if condition in gcc's reload.c
#56#ifdef should be shot
Re: 54-line if condition in gcc's reload.c
#571) The goals of Reload are very complex.
http://gcc.gnu.org/wiki/reload
"Reload does everything, and probably no one exactly knows how much that is. But to give you some idea:
Spill code generation
Instruction/register constraint validation
Constant pool building
Turning non-strict RTL (Register Transfer Language, a very low level intermediate representation used in the backends of GCC) into strict RTL (doing more of the above in evil ways).
Register elimination--changing frame pointer references to stack pointer references
Reload inheritance--essentially a builtin CSE (Common Subexpression Elimination) pass on spill code"
Reload achieved them for the last 25 years(!)
2) There are more modern approaches to reach such goals, but knowing 1) it is a lot of work before the goals can be achieved by some alternative code for all platforms (I don't know how far the developers got at the moment)
3) "Local Register Allocator Project" presentation by Vladimir Makarov, working for RedHat:
http://gcc.gnu.org/wiki/cauldron2012?action=AttachFile&do=ge...
Re: 54-line if condition in gcc's reload.c
#58Earlier quoted context omitted.
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.
Re: 54-line if condition in gcc's reload.c
#59 x && y || !x && z
In this absence of side-effects, this basically implements a 2-input multiplexer and is identical to x ? y : z
In the 54-line condition the first obvious thing I'd factor out is SUBREG_REG(in) and GET_MODE(SUBREG_REG(in)), and then work out what else is duplicated from there. Here's my attempt at making this a little more readable. It's only 2 lines less, but this gets rid of all the repeated uppercase:Re: 54-line if condition in gcc's reload.c
#60No 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?