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

Another InstCombine issue #1620

Closed
asl opened this issue Mar 10, 2007 · 6 comments
Closed

Another InstCombine issue #1620

asl opened this issue Mar 10, 2007 · 6 comments
Labels
bugzilla Issues migrated from bugzilla miscompilation regression

Comments

@asl
Copy link
Collaborator

asl commented Mar 10, 2007

Bugzilla Link 1248
Resolution FIXED
Resolved on Feb 22, 2010 12:44
Version trunk
OS All
Blocks #1538
Attachments Bytecode
CC @lattner

Extended Description

Consider the attached bytecode. This is just -O0 compiled bytecode from gcc
testsuite.

Running "opt -instcombine" will lead to "eq" comparison turn to "slt", which is
definitely wrong.

@lattner
Copy link
Collaborator

lattner commented Mar 13, 2007

I think that this is trying to simplify (x sdiv 12) != -6

@lattner
Copy link
Collaborator

lattner commented Mar 13, 2007

Here's a reduced testcase:
define i1 @​test(i32 %tmp6) {
%tmp7 = sdiv i32 %tmp6, 12 ; [#uses=1]
icmp ne i32 %tmp7, -6 ; :0 [#uses=1]
ret i1 %0
}

instcombine compiles it to:

define i1 @​test(i32 %tmp6) {
icmp sgt i32 %tmp6, -73 ; :0 [#uses=1]
ret i1 %0
}

which is wrong for an input of -70.

-Chris

@lattner
Copy link
Collaborator

lattner commented Mar 13, 2007

This appears to be fallout from the signless types change.

The problem is AddWithOverflow in Instcombine. It is not calculating overflow correctly if the operands
are signed. The getZExtValue() < getZExtValue() comparison needs to do a signed comparison if the input
operands are signed (requiring a bool to be passed in).

Reid, plz investigate.

-Chris

@llvmbot
Copy link
Collaborator

llvmbot commented Mar 14, 2007

Mine.

@llvmbot
Copy link
Collaborator

llvmbot commented Mar 21, 2007

Making the AddWithOverflow change doesn't fix the problem.

@llvmbot
Copy link
Collaborator

llvmbot commented Mar 22, 2007

Turns out there were two bugs. The AddWithOverflow needed to be APIntified and
to deal with the sign properly. Also, in the case of:
%Y = sdiv iN %X, C1
icmp pred iN %Y, -C2
there was an off-by-one error in the high bound for the range test that is
produced in the replacement.

This patch was applied:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070319/046072.html

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
kitano-metro pushed a commit to RIKEN-RCCS/llvm-project that referenced this issue Feb 14, 2023
kitano-metro pushed a commit to RIKEN-RCCS/llvm-project that referenced this issue Feb 14, 2023
kitano-metro pushed a commit to RIKEN-RCCS/llvm-project that referenced this issue Feb 14, 2023
troelsbjerre pushed a commit to troelsbjerre/llvm-project that referenced this issue Jan 10, 2024
 lldbutil: add a retry mechanism for the ios simulator
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 miscompilation regression
Projects
None yet
Development

No branches or pull requests

3 participants