1. 3
  1. 2

    This looks like C# is hitting the same problem that causes a bunch of Java perf issues. The Create call requires that a new object is created. In particular, it requires that the address of the created vector does not alias the other vectors and so the compiler is not able to do any kind of constant folding. Given that two of these vectors are constants, I would expect that making them static would fix the multiple-creation issue. The compiler would then know that these are the same vector and be free to reuse them.

    At a first glance, this doesn’t look to be related to inlining at all. If the inlined source code also created the vectors three times then you’d probably see the same issue in the final output. The moral of this story is to be sure that the root cause of your bug really is what you think it is.