Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

asmgen: (compile_arg) not compatible asm_arg #930

Open
y4cer opened this issue Oct 16, 2024 · 1 comment
Open

asmgen: (compile_arg) not compatible asm_arg #930

y4cer opened this issue Oct 16, 2024 · 1 comment

Comments

@y4cer
Copy link

y4cer commented Oct 16, 2024

Good day!

I encountered the internal compilation error, which kindly asked to report issue here

"src/util.jazz", line 33 (2-36):                                                                                                                                                                            
internal compilation error in function dot_product:                                                                                                                                                         
  asmgen: (compile_arg) not compatible asm_arg                                                                                                                                                              
Please report at https://github.com/jasmin-lang/jasmin/issues                                                                                                                                               
make: *** [Makefile:18: build/jasmin/util.s] Error 1  

Here is the code snippet, the error happens in the second for loop, I also added comments there for better visibility.

export
fn dot_product(reg u64 l, reg u64 r) -> reg u64 {

	inline u64 rec, nwords;

	// wordwise dot product
	inline int i;
	reg u64 w;
	w = 0;
	nwords = n / 64;
	for i=0 to nwords {
		w ^= (u64)[l + i] & (u64)[r + i];
	}

	// bytewise dot product
	inline int start;
	start = nwords * 64;
	rec = n % 64;
	reg u64 b, tmp;
	b = 0;
	for i=0 to rec {
		tmp = (u64)[l + start + i] & 0xff;         // <- ERROR IS HERE
		b ^= tmp;
		tmp = (u64)[r + start + i] & 0xff;        // <- ERROR IS HERE
		b ^= tmp;
	}
	reg u64 res;
	res = 0;

	res ^= (w & 0xff);
	res ^= b;

	return b;
}

At the time of this issue resolution, is there a workaround for this problem?

@vbgl
Copy link
Member

vbgl commented Oct 16, 2024

Thanks for the report. There is indeed a bug.

If you want to just load 8 bits, you can use an 8-bit load: tmp = (u8)[l + start + i];.

There is probably an other issue in your program there: w ^= (u64)[l + i] & (u64)[r + i]; You are trying to do two memory accesses, and two logic/arithmetic operations in a single instructions. That’s too much. You’ll have to split this into smaller steps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants