compiler-optimization

Is my construction of SSA correct? (Renaming)

 ̄綄美尐妖づ 提交于 2020-08-10 18:55:54
问题 I've been learning about ssa (static single assignment form), and I was given the following graph with phi functions inserted, but the graph hasn't been renamed: I had to rename the variables, and this is what I got: I am very unsure that this is correct. Did I rename the variables correctly? Is this minimal ssa? I am using this algorithm from here (Cytron, et. al's paper) to rename the variables. Please help! :) 回答1: No, your graph is not correct. The phi-functions and renaming for x and y

Is my construction of SSA correct? (Renaming)

吃可爱长大的小学妹 提交于 2020-08-10 18:54:52
问题 I've been learning about ssa (static single assignment form), and I was given the following graph with phi functions inserted, but the graph hasn't been renamed: I had to rename the variables, and this is what I got: I am very unsure that this is correct. Did I rename the variables correctly? Is this minimal ssa? I am using this algorithm from here (Cytron, et. al's paper) to rename the variables. Please help! :) 回答1: No, your graph is not correct. The phi-functions and renaming for x and y

Data Alignment: Reason for restriction on memory address being multiple of data type size

寵の児 提交于 2020-08-04 16:27:50
问题 I understand the general concept of data alignment, but what I do not understand is the restriction on memory address value, forced to be a multiple of the size of underlying data type. This answer explains the data alignment well. Quote: Let's look at a memory map: +----+ |0000| |0001| +----+ |0002| |0003| +----+ |0004| |0005| +----+ | .. | At each address there is a byte which can be accessed individually. But words can only be fetched at even addresses. So if we read a word at 0000, we

ArrayPool create method in C#

会有一股神秘感。 提交于 2020-07-22 05:35:45
问题 I was using with ArrayPool in C#. I wanted to create my own pool with max no of arrays 5 and max size of array 1050000. I used this ArrayPool.Create() method. I am not able to understand one thing - i am trying to rent from the pool 10 times in the snippet below ,although i specified max arrays to be 5 , then why is it not showing any error. Also, i specified max length to be 1050000.Then how am i able to rent a 4200000 array without any error ? byte[] buffer; ArrayPool<byte> pool = ArrayPool

Can multiple 'const reference' variables share the same memory?

拜拜、爱过 提交于 2020-07-09 08:44:29
问题 I'm wondering if there's a memory cost to having multiple "constant reference" variables in the same scope pointing to the same object: const Animal& animal = getAnimal(); const Dog& dog = static_cast<const Dog&>(animal); Conceptually, animal and dog are two variables, each of pointer size, and thus would take up 2 registers (or a 2*pointer-size region on the stack). But (assuming that there's no multiple inheritance etc.), the compiler could know that they both must hold the same pointer

Binary to binary cast with JSONb

情到浓时终转凉″ 提交于 2020-06-29 05:04:11
问题 How to avoid the unnecessary CPU cost? See this historic question with failure tests. Example: j->'x' is a JSONb representing a number and j->'y' a boolean. Since the first versions of JSONb (issued in 2014 with 9.4) until today (6 years!), with PostgreSQL v12... Seems that we need to enforce double conversion: Discard j->'x' "binary JSONb number" information and transforms it into printable string j->>'x' ; discard j->'y' "binary JSONb boolean" information and transforms it into printable

How to demonstrate Java instruction reordering problems?

坚强是说给别人听的谎言 提交于 2020-06-24 02:58:28
问题 With Java instruction reordering the execution order of the code is changed by the JVM at compile time or run time, possibly causing unrelated statements to be executed out-of-order. So my question is: Can someone provide an example Java program/snippet, that reliably shows an instruction reordering problem, that is not caused also by other synchronization issues ( such as caching/visibility or non-atomic r/w, as in my failed attempt at such a demo in my previous question ) To emphasize, I am

How to demonstrate Java instruction reordering problems?

痞子三分冷 提交于 2020-06-24 02:57:21
问题 With Java instruction reordering the execution order of the code is changed by the JVM at compile time or run time, possibly causing unrelated statements to be executed out-of-order. So my question is: Can someone provide an example Java program/snippet, that reliably shows an instruction reordering problem, that is not caused also by other synchronization issues ( such as caching/visibility or non-atomic r/w, as in my failed attempt at such a demo in my previous question ) To emphasize, I am

Go lang empty struct confusing feature [duplicate]

半腔热情 提交于 2020-06-17 15:48:06
问题 This question already has answers here : why struct arrays comparing has different result (1 answer) Addresses of slices of empty structs (2 answers) Closed 14 days ago . Here is my code: package main import ( "fmt" ) type A struct{} func main() { var ad, bd A res1 := &ad == &bd res2 := ad == bd fmt.Println(res1, res2)// true true fmt.Printf("%p, %p\n", &ad, &bd) // 0x57bb60, 0x57bb60 } Now if I comment the last line of main function like this: package main import ( "fmt" ) type A struct{}

Why can the compiler not optimize floating point addition with 0? [duplicate]

眉间皱痕 提交于 2020-06-10 02:25:12
问题 This question already has answers here : Why does MSVS not optimize away +0? (2 answers) Closed 8 days ago . I have four identity functions which do essentially nothing. Only multiplication with 1 could be optimized by clang to a single ret statement. float id0(float x) { return x + 1 - 1; } float id1(float x) { return x + 0; } float id2(float x) { return x * 2 / 2; } float id3(float x) { return x * 1; } And the following compiler output is: (clang 10, at -O3) .LCPI0_0: .long 1065353216 #