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 1263 - missed bitcast optimization
Summary: missed bitcast optimization
Status: RESOLVED FIXED
Alias: None
Product: libraries
Classification: Unclassified
Component: Scalar Optimizations (show other bugs)
Version: 1.0
Hardware: All All
: P enhancement
Assignee: Chris Lattner
URL:
Keywords: code-quality
Depends on:
Blocks:
 
Reported: 2007-03-21 11:36 PDT by Duncan Sands
Modified: 2010-02-22 12:51 PST (History)
1 user (show)

See Also:
Fixed By Commit(s):


Attachments
Small but not completely reduced testcase (579 bytes, text/plain)
2007-03-21 11:37 PDT, Duncan Sands
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Duncan Sands 2007-03-21 11:36:00 PDT
In the attached .ll you can find:
        %tmp64 = bitcast i32* %tmp1 to { i32 }*         ; <{ i32 }*> [#uses=1]
        %tmp65 = getelementptr { i32 }* %tmp64, i32 0, i32 0            ; 
<i32*> [#uses=1]
Thus %tmp65 is equal to %tmp1, but the optimizers miss this.  This strange
construction was produced by llvm-convert, or so it seems.  I will try to
find out why it is being produced in the first place.
Comment 1 Duncan Sands 2007-03-21 11:37:51 PDT
Created attachment 710 [details]
Small but not completely reduced testcase
Comment 2 Chris Lattner 2007-03-25 15:44:26 PDT
Nice catch.  Testcase here: Transforms/InstCombine/cast2.ll:test3

Patch here:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070319/046249.html

-Chris
Comment 3 Duncan Sands 2007-03-29 03:18:31 PDT
Actually, this could be more general: trailing zeros can be eliminated,
at least if all indices are constant.  For example, indices "1,0" could
be turned into "1" plus a bitcast.
Comment 4 Chris Lattner 2007-03-29 11:32:33 PDT
Of course.  Again, the goal isn't to reimplement instcombine :)