retdec icon indicating copy to clipboard operation
retdec copied to clipboard

Detect idiom: packing a 64-bit int from 2 32-bit ints

Open KOLANICH opened this issue 4 years ago • 2 comments

NumericT<64> int32From2Int16(NumericT<32> lo, NumericT<32> hi){
	return lo | (hi << 32);
}

KOLANICH avatar Sep 19 '21 21:09 KOLANICH

The same as in #1019 - an input sample to reproduce would help.

PeterMatula avatar Oct 01 '21 13:10 PeterMatula

Is this some kind of compiler idiom?

IDK. May be generated (for unaligned access) and may be not. But it is surely widely used when coded manually.

Do you have some input on where it occurs?

It is a basic block for higher-level idioms. It is they that occur.

What do we produce at the moment?

Sometimes bit operations, sometimes integer arithmetics with the same effect.

What do you suggest we should produce? (Do I guess right that you propose a function call?)

Yeah. Add an (possibly inline) function and use it every time the idiom occurs.

KOLANICH avatar Oct 01 '21 16:10 KOLANICH