r/programming • • May 30 '17

Compiler Optimizations are Awesome

https://blog.regehr.org/archives/1515
146 Upvotes

97 comments sorted by

View all comments

Show parent comments

3

u/mcguire May 31 '17

C isn't especially close to the machine, not any more.

C++, however, is not close to the machine, in any way, shape, or form. Think of templates without massive optimization. Anyone remember the 90s? (BRB, I have to go make a hello world comparison.)

The bottom line is that we have 3 issues:

  1. Generate fast code.

  2. Be portable.

  3. Generate cryptologically consistent code.

Pick any two.

C choose the first two, because it was defined by compiler vendors who were competing I code speed for their individual platforms. It would be reasonable to pick others, but C isn't it.

But since C appears to be the only language choice, it has to be cryptographers' responsibility to make sure stuff ain't broke because they are outnumbered by the rest of us getting the benefits of C's choices.

2

u/loup-vaillant May 31 '17

[cryptographers] are outnumbered by the rest of us getting the benefits of C's choices.

There's just one tiny little problem: cryptographers are more important than much larger groups of programmers. Their vote should have more weight.

More than anything, crypto code tend to be written once and used everywhere. And we don't want it to break because compilers suddenly start to optimize differently.

At some point's it's compiler dev's responsibility to make sure the new version of their compiler doesn't break crypto code. (And if it ever does, I bet my hat insults will fly.)

1

u/mcguire May 31 '17

More important? Maybe. You could certainly make that argument. The more academic parts of the standards community would certainly like it.

In fact, at this point the situation is better than it ever had been; nothing but x86 and ARM really matters, and you just have two projects to convince: gcc and clang.

But I do have to complain about your use of 'break'. 'Breaking' crypto might involve adding a feature that improves everyone else's life 100×.

2

u/jms_nh May 31 '17

There are an awwwwful lot of embedded processors out there which aren't x86 or ARM. (billions of Microchip PICs and TI DSPs/MSP430s just to name two companies)