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

miscompilation due to switch -> shift/and code #1697

Closed
lattner opened this issue Apr 14, 2007 · 6 comments
Closed

miscompilation due to switch -> shift/and code #1697

lattner opened this issue Apr 14, 2007 · 6 comments
Assignees
Labels
bugzilla Issues migrated from bugzilla llvm:codegen miscompilation

Comments

@lattner
Copy link
Collaborator

lattner commented Apr 14, 2007

Bugzilla Link 1325
Resolution FIXED
Resolved on Feb 22, 2010 12:45
Version 1.0
OS All
Attachments Test .ll file, .s file with shift/and enabled, .s file with shift/and disabled
CC @asl

Extended Description

Shift/And lowering is producing invalid code. I'm not sure but I think that this is the issue:

LBB1_2: ;cond_next67
lbz r2, 0(r29)
li r3, 1
cmplwi cr0, r2, 32
slw r3, r3, r2
bgt cr0, LBB1_4 ;bb101.preheader

This allows a shift of 32. On PPC, this will produce the same value as shifting by 31. On X86, this
produces the same value as shifting by 0. This is the switch in question:

switch i8 %tmp69, label %cond_next67.bb101_crit_edge [
	 i8 32, label %cond_next67.bb37_crit_edge
	 i8 9, label %cond_next67.bb37_crit_edge2
	 i8 10, label %cond_next67.bb37_crit_edge3
	 i8 13, label %cond_next67.bb37_crit_edge4
	 i8 12, label %cond_next67.bb37_crit_edge5
]

That said, it is an impressive code size win :)

-Chris

@lattner
Copy link
Collaborator Author

lattner commented Apr 14, 2007

assigned to @asl

@lattner
Copy link
Collaborator Author

lattner commented Apr 14, 2007

This also broke ppc bootstrap.

@asl
Copy link
Collaborator

asl commented Apr 14, 2007

Mine. However, I thought this case was fixed before my commit :) Ok. Will
investigate.

@asl
Copy link
Collaborator

asl commented Apr 14, 2007

Fixed with:

http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070409/047507.html
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070409/047506.html

Sorry for the breakage. I wasn't be able to test things on PowerPC and I cannot
understand PowerPC assembler yet :) Chris, could you please verify?

I also fixed some "latent" bug, which can be only triggered on 64-bit platforms.
Jeff, could you please check, whether this fixes some bugs for you or not.

@llvmbot
Copy link
Collaborator

llvmbot commented Apr 14, 2007

It seems to work on freebsd/amd64.

@lattner
Copy link
Collaborator Author

lattner commented Apr 14, 2007

Verified that 253.perlbmk passes on ppc now. ppc bootstrap still broken, I'll file a new bug if it's shift/
and.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
troelsbjerre pushed a commit to troelsbjerre/llvm-project that referenced this issue Jan 10, 2024
Cherry-pick recent JIT API updates to llvm.
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla llvm:codegen miscompilation
Projects
None yet
Development

No branches or pull requests

3 participants