News for hackers. Stuff that matters.

UniQP

Re:Refactoring using mathematical properties of min on Friday June 15, 2018 @10:00AM (#17319800)
The blog post doesn't mention integer overflows. If integers wrap around on overflow, min(INT_MIN - 1, 0 - 1) = -1 but min(INT_MIN, 0) - 1 = INT_MAX. However, in PHP the values are converted to floats, which should preserve the equation min(a -c, b - c) = min(a, b) - c.
Re:How many coders does it take to change a lightbulb on Tuesday November 14, 2017 @08:39AM (#15694829)
None, it's a hardware problem.
Re:Go 1.7 is released on Tuesday August 16, 2016 @05:55PM (#12300926)
Since there is also a programming language called C2, I took a look at the wrong compiler.

Can you provide a link to the source code?

Re:Go 1.7 is released on Tuesday August 16, 2016 @08:33AM (#12297010)
You can stay in SSA form even after register allocation. In libFirm the assigned registers are just attributes of the values in the SSA representation. There was some additional discussion regarding this in [1].

GCC uses a separate representation (RTL) for their backend that is not in SSA form [2]. LLVM stays in SSA form for some backend phases but lowers the SSA form before register allocation (as also mentioned in [1]).

I took a quick look at the C2 and the Graal compiler. C2 seems to use LLVM's code generator (and thus lowers SSA before register allocation) but Graal seems to support SSA-based register allocation, nice.

[1] https://news.ycombinator.com/item?id=11210948

[2] https://en.wikibooks.org/wiki/GNU_C_Compiler_Internals/GNU_C...

Re:Go 1.7 is released on Tuesday August 16, 2016 @02:49AM (#12295939)
SSA is standard for the middle end but not for the backend. According to my knowledge there are only two compilers with an SSA-based backend: libFirm (www.libfirm.org) and the Go compiler.
Re:Cracking the Adventure Time cipher on Tuesday August 02, 2016 @03:29AM (#12208336)
Does anyone know an open source tool for monoalphabetic (or polyalphabetic) substitution that can handle arbitrary dictionaries?
Re:Golang SSA performance numbers on Friday March 11, 2016 @03:51AM (#11265490)
Compile time is an issue of C++ but not of C.
Re:Golang SSA performance numbers on Friday March 11, 2016 @02:57AM (#11265312)
[citation needed]
Re:Golang SSA performance numbers on Friday March 11, 2016 @02:56AM (#11265309)
I'm sure, you can also self-compile the tip. Would be really interesting if this was done for benchmarks.
Re:Golang dev.ssa branch merged into tip on Wednesday March 02, 2016 @01:02PM (#11211681)
> So it's not impossible, but libfirm avoids it or performs the necessary phi insertion in various places to avoid creating invalid SSA for the representation it has.

It's impossible to have one edge pointing to multiple reaching definitions.

Re:Golang dev.ssa branch merged into tip on Wednesday March 02, 2016 @12:19PM (#11211335)
> There are theoretical benefits, but in practice, LLVM does pretty well with it's current scheme.

I think having a decoupled spilling phase is nice feature of the SSA-based scheme. However, I don't say that LLVM (or GCC) should switch to the SSA-based scheme. I just appreciate that the Go compiler switched to the SSA-based scheme, because it may bring some new insights to the research community.

Re:Golang dev.ssa branch merged into tip on Wednesday March 02, 2016 @12:05PM (#11211221)
> At some point it lowers out of SSA, but you have to do that at some point anyway.

libfirm never goes out of SSA (since it uses a graph-based representation it's simply impossible: the data dependency edges need one target). It converts the programm to CSSA and assigns the same register to all phi operands. When finally emitting the program, phi nodes emit nothing.

Re:Golang dev.ssa branch merged into tip on Wednesday March 02, 2016 @11:22AM (#11210879)
Yes, in the middle end, but they don't have an SSA-based back end (for example SSA-based register allocation).
Re:Golang dev.ssa branch merged into tip on Wednesday March 02, 2016 @10:15AM (#11210394)
After libfirm [1], the Go compiler now seems to be the second mature compiler with an SSA-based backend. I hope more compilers will follow.

I missed some references to corresponding papers in the source code. For instance, is the register allocator an implementation of "Linear Scan Register Allocation on SSA Form" [2]?

Also some facts mention in comments [3] are a bit scary but I guess this will be resolved over time.

[1] http://pp.ipd.kit.edu/firm/

[2] http://www.christianwimmer.at/Publications/Wimmer10a/Wimmer1...

[3] https://github.com/golang/go/blob/master/src/cmd/compile/int...

Re:Golang dev.ssa branch merged into tip on Wednesday March 02, 2016 @09:57AM (#11210270)
As stated in [1] they use a variant of "Simple and Efficient Construction of Static Single Assignment Form" [2], which does not require a dominator tree (or a liveness analysis).

[1] https://github.com/golang/go/blob/master/src/cmd/compile/int...

[2] http://pp.info.uni-karlsruhe.de/uploads/publikationen/braun1...

Re:Register Allocation by Graph Coloring (2003) on Monday February 22, 2016 @02:38AM (#11149191)
libfirm (http://pp.ipd.kit.edu/firm/) uses SSA-based register allocation (http://d-nb.info/986273813/34), which allows a decoupled spilling phase. Moreover, the register assignment becomes polynomial, while register coalescing remains NP-complete.
Re:Nuitka Progress in 2015 – Python Compiler on Friday January 29, 2016 @10:13AM (#10995616)
You are right, this should be static single assignment.
Re:STOKE – a stochastic optimizer for x86_64 assembly on Wednesday January 20, 2016 @05:23AM (#10937118)
There are a lot of compiler optimizations that uses global analyses/optimizations that are not covered by optimizing a sequence of assembly instructions. Thus, I doubt that CompCert + STOKE would reach the code quality of production compilers.

Nevertheless, I agree that superoptimizers ofter find optimizations that are not considered by the compiler engineers. Another good example is the Optgen tool [1] that also identified missing (machine-independent) optimizations in all production compilers.

[1] http://pp.ipd.kit.edu/optgen/

Re:STOKE – a stochastic optimizer for x86_64 assembly on Tuesday January 19, 2016 @09:08AM (#10930808)
That's because a) the initial STOKE paper (2013) is older than Souper (initial commit 2014) and b) there is no Souper paper so far
Documentation->LLVM: http://pp.ipd.kit.edu/firm/LLVM ;-)
Re:Go 1.6 Beta Released on Monday December 21, 2015 @10:18AM (#10771436)
That sounds like an (e-)SSA-based optimization but not like an SSA backend.
Re:Go 1.6 Beta Released on Friday December 18, 2015 @08:43AM (#10758340)
Does anyone know the current state of the SSA backend mentioned in https://news.ycombinator.com/item?id=9099744 ?
Re:Jump Threading on Thursday October 29, 2015 @08:54AM (#10470573)
Jump threading can also enables additional optimizations. For instance, if you apply jump threading to

int eight(int a) { int b; if (a) { b = 1; } else { b = a; } b += 3; if (a) { return b + b; } else { return b + 5; } }

you duplicate the "b += 3;" but both branches can be optimized afterwards. In fact, the function always returns 8.

Re:Souper – A Superoptimizer for LLVM IR on Wednesday October 28, 2015 @09:43AM (#10464353)
I do not have an example for Souper, but the Optgen tool uses similar techniques and the paper provides a list of missing optimizations for LLVM, GCC and ICC: http://pp.info.uni-karlsruhe.de/uploads/publikationen/buchwa... .
Re:A Few Synthesizing Superoptimizer Results on Monday July 27, 2015 @05:16PM (#9958067)
The permutation problem is not related to IR superoptimization itself.

The goal of an optimization pass is to improve the performance of an average, and that's exactly what the IR superoptimization does.

Re:A Few Synthesizing Superoptimizer Results on Monday July 27, 2015 @04:35AM (#9954039)
My advisor once said "Optimization means: sometimes, it is not getting worse", and that's excactly what happens if you perform any optimization on IR level. You don't have any guarantee that your result is optimal (regarding whatever). That's exactly the reason why Massalin introduced the term superoptimization, because on machine level you can provide such guarantees for the considered instruction sequence.

Of course there a cases where preventing an IR optimization can trigger a more powerful one and the resulting code gets better. However, in general I would say it's the other way around: Performing the IR superoptimization leads to better code quality.

Re:A Few Synthesizing Superoptimizer Results on Monday July 27, 2015 @04:18AM (#9954000)
The advantage of performing superoptimization on IR level is that you have explicit data dependencies (due to SSA form). Thus you don't have unrelated instructions in between. Figure 1 of the cited Optgen paper http://pp.info.uni-karlsruhe.de/uploads/publikationen/buchwa... shows an example that can be optimized with IR-based superoptimization but not with a machine-specific one.

In summary, no approache subsumes the other one. Thus, it is worthwhile to have them both.

Re:CPU registers and OCaml on Monday June 22, 2015 @06:53AM (#9757417)
What do you mean by more advanced?

The LLVM implementation is more mature from a software point of view, but libFirm's implementation supports more PBQP reductions, and thus may find a better PBQP solution.