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

Missed optimization during register coalescing #8484

Closed
llvmbot opened this issue Sep 8, 2010 · 3 comments
Closed

Missed optimization during register coalescing #8484

llvmbot opened this issue Sep 8, 2010 · 3 comments
Labels
bugzilla Issues migrated from bugzilla code-quality llvm:regalloc

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Sep 8, 2010

Bugzilla Link 8112
Version trunk
OS Linux
Reporter LLVM Bugzilla Contributor
CC @asl,@gandhi56,@stoklund

Extended Description

Compiling the following C code with:

$ clang -cc1 -triple thumbv5-u-u -S -O2 test.c -o -

typedef unsigned long long t;
t foo(t a, t b)
{
t a4 = b^a^18;
return a4;
}

emits:

eors	r1, r3
mov	r3, r0
eors	r3, r2
movs	r0, #​18
eors	r0, r3
bx	lr

instead of

eors	r1, r3
eors	r0, r2
movs	r4, #​18
eors	r0, r4
bx	lr

IR:
define arm_aapcscc i64 @​foo(i64 %a, i64 %b) nounwind readnone {
entry:
%xor = xor i64 %a, 18 ; [#uses=1]
%xor2 = xor i64 %xor, %b ; [#uses=1]
ret i64 %xor2
}

The first move could be eliminated if the imm value is moved to a scratch register instead of moving it to r0 which is used as a return value register.

I noticed this while developing a new backend, however it can be reproduced in ARM aswell (shown here), so it's not a backend issue.
Jakob Stoklund did a great analysis explaining where the problem is that can be found here:
http://lists.cs.uiuc.edu/pipermail/llvmdev/2010-September/034430.html

@stoklund
Copy link
Mannequin

stoklund mannequin commented Sep 8, 2010

Thanks,

I'll probably be looking into improving the coalescer after live range splitting is done.

@gandhi56
Copy link
Contributor

gandhi56 commented Mar 7, 2021

It looks like this bug has already been dealt with when I ran the code using clang-10?

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
@arsenm
Copy link
Contributor

arsenm commented Aug 8, 2023

I get this now, which is equivalent to the requested result:

	eors	r1, r3
	eors	r0, r2
	movs	r2, #18
	eors	r0, r2
	bx	lr

@arsenm arsenm closed this as completed Aug 8, 2023
daniel-grumberg pushed a commit to daniel-grumberg/llvm-project that referenced this issue Apr 3, 2024
[clang][deps] Lazy dependency directives rdar://125519128
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla code-quality llvm:regalloc
Projects
None yet
Development

No branches or pull requests

3 participants