[LLVMbugs] [Bug 9561] New: Store incorrectly eliminated

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Mar 25 15:07:02 PDT 2011


http://llvm.org/bugs/show_bug.cgi?id=9561

           Summary: Store incorrectly eliminated
           Product: new-bugs
           Version: 2.9
          Platform: PC
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: davidterei at gmail.com
                CC: llvmbugs at cs.uiuc.edu


Created an attachment (id=6362)
 --> (http://llvm.org/bugs/attachment.cgi?id=6362)
Testcase

LLVM 2.9rc2 appears to incorrectly eliminate a store on Mac OSX (32bit).

The test case attached is a simple function that does 3 stores. opt appears to
think that the third and final store overlaps the first store so it eliminates
it. This is incorrect though as the third store doesn't overlap the first.

Here is the stores in question before optimisation by llvm opt:

---------------------------------------------------------------------
%ln2gr = ptrtoint [0 x i32]* @ghczmprim_GHCziTypes_ZMZN_closure to i32
%ln2gs = add i32 %ln2gr, 1
%ln2gt = load i32** %Sp_Var
%ln2gu = getelementptr i32* %ln2gt, i32 0
store i32 %ln2gs, i32* %ln2gu

%ln2gv = ptrtoint [0 x i32]* @stg_ap_p_info to i32
%ln2gw = load i32** %Sp_Var
%ln2gx = getelementptr i32* %ln2gw, i32 -1
store i32 %ln2gv, i32* %ln2gx

%ln2gy = load i32** %Base_Var
%ln2gz = getelementptr i32* %ln2gy, i32 14
%ln2gA = bitcast i32* %ln2gz to double*
%ln2gB = load double* %ln2gA
%ln2gC = load i32** %Sp_Var
%ln2gD = getelementptr i32* %ln2gC, i32 -3
%ln2gE = bitcast i32* %ln2gD to double*
store double %ln2gB, double* %ln2gE
---------------------------------------------------------------------

After optimisation we have:

---------------------------------------------------------------------
%ln2gx = getelementptr i32* %Sp_Arg, i32 -1
store i32 ptrtoint ([0 x i32]* @stg_ap_p_info to i32), i32* %ln2gx
%ln2gz = getelementptr i32* %Base_Arg, i32 14
%ln2gA = bitcast i32* %ln2gz to double*
%ln2gB = load double* %ln2gA
%ln2gD = getelementptr i32* %Sp_Arg, i32 -3
%ln2gE = bitcast i32* %ln2gD to double*
store double %ln2gB, double* %ln2gE
---------------------------------------------------------------------

Optimisation flags to trigger:
  * '-O1' will trigger.
  * '-basicaa -scalarrepl-ssa -early-cse -dse' seems to be the smallest set of
flags for it to trigger

General Notes:
  * Removing the second store doesn't have an effect.
  * Changing the 'getelementptr' indexes used for the second and third store
will often fix the bug (even if they are kept 3 apart still).
  * That the first store is using '0' as the 'getelementptr' index seems to be
relevant.
  * Doesn't occur on Linux x64. Haven't test on 32bit Linux so either its a
32bit specific bug or Mac OS X specific bug.

llvm 2.8 doesn't have this behaviour. This bug causes test 4383 in the GHC
testsuite to fail. Other than this bug every other test (around 2100 of them)
passes using llvm 2.9.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list