Skip to content

Add constant-folding (simplification) of trivial cases of double-precision multiplication (MulDoublePrecXXXX) #6625

@mostobriv

Description

@mostobriv

What is the feature you'd like to have?
Constant-folding inside of IL_MUL(U)_DP, AFAIK currently it's not supported(?)

Is your feature request related to a problem?
not much

Are any alternative solutions acceptable?
Well, i can override arch plugin to change lifting in such way its won't use MUL_DP but it looks like overkill to me.

Additional Information:
Example code for arm64:

#include <stdint.h>
#include <stdio.h>


__attribute__((always_inline))
uint64_t mymul(uint32_t a, uint32_t b) {
	uint64_t result = 0;
	__asm volatile (
		"umull %x[res], %w[first], %w[second]"
		: [res] "=r" (result)
		: [first] "r" (a), [second] "r" (b)
	);

	return result;
}


int main() {
	if (mymul(5, 3) == 15) {
		puts("15 indeed");
	} else {
		puts("pls, hide me out :C");
	}

	return 0;
}

This snippet uses umull instruction, with a pretty trivial case that can be folded (two constant integers), however here is how it looks like in MLIL and HLIL:

Image Image

Here is the binary i've tested on:
umull_test.zip

Metadata

Metadata

Assignees

Labels

Component: CoreIssue needs changes to the coreCore: DataflowRelated to the Possible Value Set and Register Value systemsCore: HLILIssue involves High Level ILCore: MLILIssue involves Medium Level ILEffort: TrivialIssue should take < 1 dayIL OptimizationIssue involving optimization of representation (not correctness)Impact: LowIssue is a papercut or has a good, supported workaround

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions