LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 1107 - -instcombine miscompilation of MiBench/consumer-typeset
Summary: -instcombine miscompilation of MiBench/consumer-typeset
Status: RESOLVED FIXED
Alias: None
Product: libraries
Classification: Unclassified
Component: Scalar Optimizations (show other bugs)
Version: trunk
Hardware: All All
: P normal
Assignee: Chris Lattner
URL:
Keywords: miscompilation
Depends on:
Blocks:
 
Reported: 2007-01-12 00:55 PST by Reid Spencer
Modified: 2018-11-07 00:17 PST (History)
1 user (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Reid Spencer 2007-01-12 00:55:23 PST
I have been trying to solve a little mystery. After resolving various issues
with the test case itsellf (MultisSource/Benchmarks/MiBench/consumer-typeset), I
have determined that there is a codegen bug that this test triggers when
-instcombine is run. Here's how I know this:

1. If you run the Output/consumer-typeset.linked.rbc file through lli in JIT 
   mode it works fine.

2. All three backends (llc,jit,cbe) fail in the same way. They all produce the
   same incorrect output. This indicates a misoptimization rather than a code
   gen bug.

3. I used findmisopt to find the first optimization that caused the output to 
   differ. It reported this sequence of optimizations as the first set that
   produces a difference in the output:
      -lowersetjmp -funcresolve -raiseallocs -simplifycfg -mem2reg -globalopt
      -globaldce -ipconstprop -deadargelim -instcombine
4. bugpoint produces a non-sensical reduction (two branches and a return) 

I'm wondernig if someone can bugpoint this on Darwin because I'm starting to
think that bugpoint doesn't work so well on Linux. In the last month, a Darwin
run of bugpoint was able to reduce a test case that a run on Linux, with the
same inputs, could not reduce. If you can reduce this on Darwin, I'll file a bug
against bugpoint.
Comment 1 Chris Lattner 2007-01-13 15:30:48 PST
I reduced it with this command:

bugpoint -llc-safe Output/consumer-typeset.noopt-llvm.bc `cat Output/gccas-pass-args` -append-
exit-code -Xlinker=-lm -input=/dev/null -output=Output/consumer-typeset.out-nat -timeout=500 
--tool-args --args -- -I data/include -D data/data -F data/font -C data/maps -H data/hyph large.lout

Bugpoint gets confused because GCC ICEs on the CBE output (thus the -llc-safe mode).

I gets it down to: opt bugpoint-tooptimize.bc -load-vn -gcse -instcombine -break-crit-edges

I'll investigate.

-Chris
Comment 2 Reid Spencer 2007-01-13 15:46:31 PST
I really need to get bugpoint fixed on Linux. This is frustrating that I can't
reduce anything on Linux except on rare occasion. I tried -llc-safe!
Comment 3 Chris Lattner 2007-01-13 16:26:45 PST
Yes, you do :)
Comment 4 Chris Lattner 2007-01-13 16:59:50 PST
It took at lot of scrutinizing, but it looks like instcombine is miscompiling:

define bool %test(i8 %A, i8 %B) {
        %a = zext i8 %A to i32          ; <i32> [#uses=1]
        %b = zext i8 %B to i32          ; <i32> [#uses=1]
        %c = icmp sgt i32 %a, %b                ; <bool> [#uses=1]
        ret bool %c
}

into:

define bool %test(i8 %A, i8 %B) {
        %c = icmp sgt i8 %A, %B         ; <bool> [#uses=1]
        ret bool %c
}

Comment 5 Chris Lattner 2007-01-13 17:12:51 PST
Here is one instcombine bugfix:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070108/042635.html

Testcase here: Transforms/InstCombine/2007-01-13-ExtCompareMiscompile.ll

This is not sufficient to fix consumer-typeset though.  Rebugpointing.
Comment 6 Chris Lattner 2007-01-13 18:56:45 PST
Here is one instcombine bugfix:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070108/042635.html

Testcase here: Transforms/InstCombine/2007-01-13-ExtCompareMiscompile.ll

The next bug isn't in instcombine.  Closing this bug to keep things simple.

-Chris
Comment 7 Reid Spencer 2007-01-14 01:15:33 PST
Works on Linux too.