Re: Branchless implementation for literal case – is it worth it?
Sven Panne
svenpanne at gmail.com
Mon Apr 20 16:16:22 UTC 2015
2015-04-20 16:41 GMT+02:00 Joachim Breitner <mail at joachim-breitner.de>:
> The conclusion I draw from your mail, at last for our case, is:
> Don’t bother (and keep the compiler code simple). Is that a correct
> reading?
Yes, I think that's the right approach. Do simple things like e.g. a
distinction between sparse cases (=> "if" cascade), lots of sparse
cases (=> some kind of decision tree) and a non-trivial number of
dense cases (jump table). For the jump table, consider computed jumps
(e.g. to a table of relative jumps, which is a common implementation
for PIC) and indirect jumps (the usual address table) in the backend.
The former could be faster than the latter (for some ARM cores IIRC),
which is not exactly intuitive. Your mileage may vary. :-)
As I said: This is our experience in a JIT, so I'd be interested in
other people's experience, too, especially for real-world programs,
not micro-benchmarks.
More information about the ghc-devs
mailing list