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

Instcombine broken after APIntification #1643

Closed
asl opened this issue Mar 25, 2007 · 13 comments
Closed

Instcombine broken after APIntification #1643

asl opened this issue Mar 25, 2007 · 13 comments
Labels
bugzilla Issues migrated from bugzilla miscompilation

Comments

@asl
Copy link
Collaborator

asl commented Mar 25, 2007

Bugzilla Link 1271
Resolution FIXED
Resolved on Nov 07, 2018 00:17
Version trunk
OS Linux
Attachments Bytecode

Extended Description

instcombine is broken now.

This leads to big miscompilations here and there.
The smallest testcase is:
Regression/C/2003-05-21-UnionBitfields.c

@llvmbot
Copy link
Collaborator

llvmbot commented Mar 25, 2007

Mine.

@llvmbot
Copy link
Collaborator

llvmbot commented Mar 25, 2007

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

fixes the "simple" test case that Chris narrowed it down to:
define i1 @​test(i32 %tmp13) {
entry:
%tmp14 = shl i32 %tmp13, 12 ; [#uses=1]
%tmp15 = lshr i32 %tmp14, 12 ; [#uses=1]
%res = icmp ne i32 %tmp15, 0 ; :3 [#uses=1]
ret i1 %res
}

InstCombine now generates:
define i1 @​test(i32 %tmp13) {
entry:
%tmp14.mask = and i32 %tmp13, 1048575 ; [#uses=1]
%res = icmp ne i32 %tmp14.mask, 0 ; [#uses=1]
ret i1 %res
}

Unfortunately, this didn't fix SingleSource/Regression/C/2003-05-21-UnionBitFields.c

@asl
Copy link
Collaborator Author

asl commented Mar 26, 2007

Unfortunately, things are still broken: Qt crashes, llvm-gcc bootstrap too.
Haven't tried mozilla, but I think it's broken too. I'm working on testcase.

@asl
Copy link
Collaborator Author

asl commented Mar 26, 2007

.ll before instcombine
Reduction from llvm-gcc bootstrap

@asl
Copy link
Collaborator Author

asl commented Mar 26, 2007

.ll after instcombine

@asl
Copy link
Collaborator Author

asl commented Mar 26, 2007

I've attached testcase from llvm-gcc bootstrap. Actually, it's
build/gengtype-yacc.o built on the stage1 (it was ok before! before fix :) ).

Fortunately, diff between .ll's is not so big. I've found only one suspicious
place (I can be surely wrong and miss something):

  • %tmp52 = shl i32 %yystacksize.5, 1 ; [#uses=1]
  • %tmp53 = add i32 %tmp52, 3 ; [#uses=1]
  • %tmp55 = lshr i32 %tmp53, 2 ; [#uses=2]
  • lshr i32 %yystacksize.5, 1 ; :4 [#uses=1]
  • %tmp55 = and i32 %4, 3 ; [#uses=2]

It seems, that presence of "add" is not taken into account...

@llvmbot
Copy link
Collaborator

llvmbot commented Mar 26, 2007

It looks like 2003-09-18-BitFieldTest.c is failing because
%tmp11 = shl i32 %tmp10, 30 ; [#uses=1]
%tmp13 = lshr i32 %tmp11, 31 ; [#uses=1]
%tmp1314 = trunc i32 %tmp13 to i8 ; [#uses=1]
%tmp131415 = zext i8 %tmp1314 to i32 ; [#uses=1]
is being turned into
lshr i32 %tmp10, 1 ; :0 [#uses=1]

Maybe it is related.

@lattner
Copy link
Collaborator

lattner commented Mar 26, 2007

FWIW, the ppc llvm-gcc bootstrap is miscompiling itself, and the following new programs fail:

New Test Failures:
Applications/d/make_dparser [LLC compile, LLC-BETA compile, JIT codegen, CBE, LLC, LLC-BETA, JIT]
Applications/JM/ldecod/ldecod [LLC compile, LLC-BETA compile, JIT codegen, CBE, LLC, LLC-BETA, JIT]
Benchmarks/Fhourstones-3.1/fhourstones3.1 [LLC compile, LLC-BETA compile, JIT codegen, CBE, LLC,
LLC-BETA, JIT]
Benchmarks/MiBench/consumer-typeset/consumer-typeset [LLC compile, LLC-BETA compile, JIT
codegen, CBE, LLC, LLC-BETA, JIT]
SPEC/CFP2006/444.namd/444.namd [LLC compile, LLC-BETA compile, JIT codegen, CBE, LLC, LLC-
BETA, JIT]
SPEC/CINT2000/176.gcc/176.gcc [LLC compile, LLC-BETA compile, JIT codegen, CBE, LLC, LLC-BETA,
JIT]
SPEC/CINT2006/403.gcc/403.gcc [LLC compile, LLC-BETA compile, JIT codegen, , LLC, LLC-BETA]
UnitTests/2004-06-20-StaticBitfieldInit [LLC compile, LLC-BETA compile, JIT codegen, CBE, LLC, LLC-
BETA, JIT]
UnitTests/2006-01-23-InitializedBitField [LLC compile, LLC-BETA compile, JIT codegen, CBE, LLC, LLC-
BETA, JIT]

-Chris

@llvmbot
Copy link
Collaborator

llvmbot commented Mar 26, 2007

With this patch:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070326/046268.html
all of the nightly test regressions are now passing, except for:
MultiSource/Applications/JM/ldecod

bugpoint has reduced an -instcombine test case with this result:
1998,2002c1998,2001
< %tmp133 = and i32 %b8, 1 ; [#uses=1]
< %tmp134 = shl i32 %tmp133, 3 ; [#uses=3]
< %tmp136 = ashr i32 %b8, 1 ; [#uses=1]
< %tmp137 = shl i32 %tmp136, 3 ; [#uses=3]
< %tmp139 = ashr i32 %tmp134, 2 ; [#uses=1]

  %tmp133 = shl i32 %b8, 3                ; <i32> [#uses=1]
  %tmp134 = and i32 %tmp133, 8            ; <i32> [#uses=2]
  shl i32 %b8, 2          ; <i32>:0 [#uses=1]
  %tmp137 = and i32 %0, -8                ; <i32> [#uses=3]

2004c2003
< store i32 %tmp139, i32* %tmp141

  store i32 0, i32* %tmp141

2008,2011c2007,2008
< icmp eq i32 %iftmp.430.0, 0 ; :0 [#uses=1]
< zext i1 %0 to i8 ; :1 [#uses=1]
< icmp ne i8 %1, 0 ; :2 [#uses=1]
< br i1 %2, label %cond_true147.exitStub, label %cond_false252.exitStub

  icmp eq i32 %iftmp.430.0, 0             ; <i1>:1 [#uses=1]
  br i1 %1, label %cond_true147.exitStub, label %cond_false252.exitStub

I'm looking at this now.

@llvmbot
Copy link
Collaborator

llvmbot commented Mar 27, 2007

This was another bad shift mask. The bugpoint reduced test case is here:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070326/046291.html

Fix patch is here:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070326/046290.html

@llvmbot
Copy link
Collaborator

llvmbot commented Mar 27, 2007

Anton,

This has passed llvm/test, llvm-test, and a bootstrap build of llvm-gcc.

I'm calling it done. If you find more bugs in instcombine (e.g. Qt, SeaMonkey),
they are probably separate issues, please file a new bug.

Thanks,

Reid.

@asl
Copy link
Collaborator Author

asl commented Mar 27, 2007

Seems ok to me. Thanks.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
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
Projects
None yet
Development

No branches or pull requests

3 participants