Viewing profile — hairtuq
hairtuq
HN member- Joined
- Wed, Mar 29, 2017, 7:54 AM UTC
- HN karma
- 85
- Public activity
- 32 items
- HN profile
- View on Hacker News ↗
About hairtuq
No profile information was provided.
Recent public activity
-
comment
Comment #45660317
The mapping after we have the leading 1's count can be done in 3 instructions (in 32-bit math) on either x86 or ARM: t = 0x2020c6 >> x return (t > 27
-
comment
Comment #44817987
If you want to optimize it a little more, you can combine isLess(s, 0x20) and isChar('"') into isLess(s ^ (kOnes * 0x02), 0x21) (this works since '"' is 0x22).
-
comment
Comment #44002144
Thanks, fixed.
-
comment
Comment #42924485
The article leaves out optimizing is_leap_year. Here is an interesting version that is correct (in the Proleptic Gregorian calendar) for 0 ((year * 1073750999) & 3221352463) How th…
-
comment
Comment #42631738
Here is a cute variant that doesn't need lzcnt nor tables, but only works up to 99,999: (((x + 393206) & (x + 524188)) ^ ((x + 916504) & (x + 514288))) >> 17 This is for integer lo…
-
comment
Comment #42404680
The author wonders: > In theory at least, the compiler can see that rule only has 256 values and create a reduced version of ca1d_rule_apply for each value. Whether it actually doe…
-
comment
Comment #40277760
Similarly, the eexpect table can be done in 3 instructions with with t = 0x3c783023f + i; return ((t >> (t & 63)) & 0xf0808088.
-
comment
Comment #34712757
I wrote a solver for Atomix ( https://github.com/falk-hueffner/atomixer ), a similar game. Technically, the only difference is that in Atomix the solution location is not predefine…
-
comment
Comment #33973795
On a related note, almost any task around shuffling or shifting bits can be improved with xor. For example the straightforward way to remove bit i is mask = -1 > 1) & mask); but wi…
-
comment
Comment #31586688
It seems you're shifting the goal posts now. The fact that consensus criticisms are not as harsh as you'd like doesn't mean that Israel is "totally off limits". Discussions and cri…
-
comment
Comment #31569062
I don't see that. For example, it has been the official position of the German government for at least 20 years to strongly criticize the Israeli settlements. There's regular criti…
-
comment
Comment #30840882
I wrote an ingredient parser that is basically just one giant regular expression: https://github.com/falk-hueffner/metric-cooking/blob/master/... The use case is a bit different (t…
-
comment
Comment #28865247
For the quite similar puzzle Atomix, it also seems like the branching factor would be much higher for backward search because upper bounds are weaker, but you can show that on aver…
-
comment
Comment #27786686
You don't necessarily need a wider type (which might be slower to work with), you can just calculate (n|1) * ((n+1)/2). Clang does something much more complicated, probably because…
-
comment
Comment #27244670
Slightly simpler: c = x ^ y; return popcount(((c >> 1) | 0x8080808080808080) - c) & 0x8080808080808080);
-
comment
Comment #27244433
Actually, e is the inverse of the xor, so (e & c1) is guaranteed to be c1, and you still need popcount(c1 & ((e & c2) + c3)).
-
comment
Comment #25301039
The name SWAR is sometimes used ( https://en.wikipedia.org/wiki/SWAR ). Indeed, even 8-bit fields can be added in parallel, using the fact that ^ is like a + that does not produce …
-
comment
Comment #24836286
There is some work on automatically generating data structure implementations from high-level specifications: https://cozy.uwplse.org/
-
comment
Comment #24670253
Since the shift count is implicitly modulo 32, you don't even need the subtraction: bool isvowel(char c) { return (1u
-
comment
Comment #23649814
I wrote a browser extension that does this (although it will of course occasionally get something wrong): https://github.com/falk-hueffner/metric-cooking
-
comment
Comment #22457049
Here's a version that at least for 64 bit might be faster: bool isPerfect(uint64_t x) { int ctz = __builtin_ctzll(x); return ((0x40051056 >> ctz) & 1) && ((x >> ctz) + 1) == (uint6…
-
comment
Comment #21916792
Red-black tree presentations are often more complicated than necessary, mostly because of (premature?) optimizations. A simple presentation can be found here: https://www.cs.tufts.…
-
comment
Comment #20960569
But it's not only impossible to decide halting faster than the program would run, but impossible at all, a much stronger statement.
-
comment
Comment #20074754
That's very unlikely to happen, since finding a counterexample or proving there isn't one is much easier than finding a program candidate, so it'll usually time out in that phase.
-
comment
Comment #20074677
I wrote a superoptimizer using z3 here: https://github.com/falk-hueffner/sematrope . The idea is to have variables that encode the program and a giant if-then-else statement that r…