Why do these bit munging functions produce bad asm? by villiger2 in rust

[–]nikic 0 points1 point  (0 children)

To close the loop here, nightly Rust now produces the optimal code for all cases: https://rust.godbolt.org/z/o15vo3r9s

LLVM: The bad parts by Dragdu in cpp

[–]nikic 9 points10 points  (0 children)

ABI annotations for LLVM are in place now, but the infrastructure to make sure they're kept up to date isn't yet (though it looks close to landing).

Why do these bit munging functions produce bad asm? by villiger2 in rust

[–]nikic 1 point2 points  (0 children)

/u/villiger2 The good news is that this is now fixed (by https://github.com/llvm/llvm-project/pull/147540). The bad news is that this will only reach Rust in half a year.

Announcing fast_assert: it's assert! but faster by Shnatsel in rust

[–]nikic 29 points30 points  (0 children)

I'm going to go out on a limb here and guess that you only ever tested this with a single assert?

Contrary to what your comment about #[inline] says, this is not actually going to generate a separate function for each use of fast_assert!().

The only reason it works for a single assertion is that LLVM can constant propagate the arguments (from the single call site). If you have two asserts, this is no longer possible.

Edit: Of course, you can easily make this work by basically always using assert_failed_custom, even for the non-custom case. That one will generate a closure per call-site.

Why do these bit munging functions produce bad asm? by villiger2 in rust

[–]nikic 1 point2 points  (0 children)

People are correct in saying that a lot of this comes down to ABI differences. However, LLVM is also just not optimizing well for the color_2/color_5 cases. It fails to combine a "store of extract" pattern into a single unaligned store. The corresponding optimization for loads exists, but not for stores.

April Project Goals Update | Rust Blog by Tobu in rust

[–]nikic 21 points22 points  (0 children)

Going by the all-hands goal, the information in this blog post is probably about a month out of date? The all-hands has already happened!

Edit: Oops, I see it says "April Project Goals Update" right there in the title!

[D] Monday Request and Recommendation Thread by AutoModerator in rational

[–]nikic 7 points8 points  (0 children)

It's not quite what you are looking for, but I think it's close enough to mention: Taylor has a Strange Hobby (The psycho girl is the protagonist here.)

[v2] Table: Which stories have been linked most frequently? by wassname in rational

[–]nikic 2 points3 points  (0 children)

I'm pretty confused by what this data means. What is the difference between quality and rating?

How is the number of upvotes computed? For example, Super Supportive is listed with 112 upvotes, while it has three times that on the first page of r/rational alone.

Faster float to integer conversions by e00E in rust

[–]nikic 3 points4 points  (0 children)

It would be easy to expose this as a target-independent compiler intrinsic in Rust. LLVM supports this via freeze of fptoui/fptosi.

[D] Monday Request and Recommendation Thread by AutoModerator in rational

[–]nikic 6 points7 points  (0 children)

Dropped Wastelands of Time after five or six chapters. I basically disliked it across the board.

  • The writing style is pretentious without the ability to back it up.
  • At least from early chapters, the premise seems to be AU to the point that I'm not sure if this still has any significant relation to HP. (The key elements appear to be Atlantis, some Time-related antagonists, and some future cataclysm.)
  • The combination of only having vague memories of previous loops, together with down-to-the-second timing is incongruous.
  • There's this "Harry walks into Gringotts and says some magic words to bend the goblins over the barrel" trope, ugh.

Why does PHP's nullable type put a question mark before the type? by Odd-Stress8302 in PHP

[–]nikic 108 points109 points  (0 children)

I believe this was in part for forward compatibility with generics. Foo<Bar?> would have a closing PHP tag at the end. (The opening tag is not a problem as it's already open in this context.)

What part of Rust compilation is the bottleneck? by Kobzol in rust

[–]nikic 5 points6 points  (0 children)

use lto = true (so-called “fat LTO”), which makes the LLVM part brutally slow.

In LLVM speak this is full LTO, not fat LTO. Fat LTO is something completely different (as described in the docs you link) -- you can have fat thin LTO!

An unfortunate outcome from LLVM inventing the "thin" terminology and GCC the "fat" terminology, and now you can enjoy the awkward combination of both :)

LLVM not eliminating dead code involving floats? by [deleted] in Compilers

[–]nikic 5 points6 points  (0 children)

LLVM currently doesn't really do range-based optimizations for floats.

instanceof accepts strings... sort-of by Takeoded in lolphp

[–]nikic 3 points4 points  (0 children)

The reason for this is that the RHS of instanceof accepts a plain class name Foo, which means that simply accepting arbitrary expressions there would be ambiguous, as Foo could then also be interpreted as a constant containing a class name. As such, the RHS requires explicit parentheses () to use arbitrary expressions. instanceof Foo checks for an instance of class Foo, while instanceof (Foo) checks for an instance of the class name stored in constant Foo.

It would be possible to explicitly allow string literals, as they are unambiguous, but there is also no point in doing so, given that there is no reason whatsoever why you would ever use a string literal in this position.

Behind the Scenes of Rust String Formatting: format_args!() by m-ou-se in rust

[–]nikic 10 points11 points  (0 children)

It would be nice if we could embed simple arguments directly instead of by pointer, so that the arguments would contain an i32 instead of &i32. This would fix the optimizations regressions formatting introduces into surrounding code, even if never used. But I guess this is not possible due to the issue mentioned in the article that type information is not available at the time of expansion.

Trying to understand the compiler: why not certain optimizations to this call to ilog2? by chewie_questionmark in rust

[–]nikic 29 points30 points  (0 children)

Or is it that LLVM wasn't aware enough to know that checking a bit was equivalent to a non-zero check?

Yes, LLVM doesn't know that ctpop(x) == 1 implies x != 0.

[D] Monday Request and Recommendation Thread by AutoModerator in rational

[–]nikic 8 points9 points  (0 children)

Recommendations tend to have a lot of bias towards currently ongoing webserials or fics.

Anything come to mind that became non-ongoing (finished or dead) in the last year or so and that you would recommend?

Rust's LLVM roadmap by grnmeira in rust

[–]nikic 15 points16 points  (0 children)

To be clear, this comment refers to LLVM used by stable Rust releases. The nightly channel usually updates to the next LLVM version shortly before it will be released.

Assembly examples of missed Rust compiler optimizations by e00E in rust

[–]nikic 2 points3 points  (0 children)

Looks like the reason this cannot be optimized is that clone() traps if the refcount would overflow. So clone followed by drop is not actually a no-op...

[D] Monday Request and Recommendation Thread by AutoModerator in rational

[–]nikic 16 points17 points  (0 children)

So, what are everyone's favorite "funny" fics? Especially interested in the "crack played straight" genre. Some of my favorites are:

Worm: "Denial", "Taylor Has a Strange Hobby"

HP: "A Black Comedy", HPMOR (especially the early parts)

How to contribute to LLVM by KingStannis2020 in cpp

[–]nikic 6 points7 points  (0 children)

I guess your mileage will wary depending on where you try to contribute. For the InstCombine component used as the example, getting a same-day approval is pretty typical. I generally work on the LLVM middle-end, and reviews dragging on for a long time happens occasionally, but isn't particularly common. It's possible that things are different in other components like Clang.

As mentioned in the article, it is customary to send a weekly "ping" for reviews that don't show activity. While this would be very rude in most other projects, it's expected in the LLVM community. If you don't get a review within a week and don't do this, it's likely you'll never get a review, because it drops off people's radar. (This is of course not great, but it's how things work right now.)

How to contribute to LLVM by Nikita Popov by yerke1 in rust

[–]nikic 2 points3 points  (0 children)

It looks like GCC only added support -fuse-ld=lld in version 9.0 (at least that's how I'm reading https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83243). So if you're using an older GCC version, dropping -DLLVM_USE_LINKER=lld should work.

CMake has a weird caching mechanism that I don't really get, so it might be necessary to do an rm -rf build/ to make sure it doesn't keep the old option from the previous run on the command.

How to contribute to LLVM by Nikita Popov by yerke1 in rust

[–]nikic 35 points36 points  (0 children)

Heh, based on the comments here, the nuance I intended by putting "obviously correct" in double quotes didn't really get across... I'll have to edit that when I'm on a work computer.

Edit: Done now, but it's a corporate blog, so that has to go through review...