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 1345 - instcombine should recover more type info
Summary: instcombine should recover more type info
Status: RESOLVED FIXED
Alias: None
Product: libraries
Classification: Unclassified
Component: Scalar Optimizations (show other bugs)
Version: 1.0
Hardware: Macintosh All
: P enhancement
Assignee: Chris Lattner
URL:
Keywords: code-quality
Depends on:
Blocks:
 
Reported: 2007-04-23 12:08 PDT by Chris Lattner
Modified: 2010-02-22 12:48 PST (History)
2 users (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 Chris Lattner 2007-04-23 12:08:42 PDT
Instcombine should eliminate the two bitcasts in this example:

define i8* @test(i8* %v) {
        %A = alloca [4 x i8*], align 16         ; <[4 x i8*]*> [#uses=3]
        %B = getelementptr [4 x i8*]* %A, i32 0, i32 0          ; <i8**> [#uses=1]
        store i8* null, i8** %B
        %C = bitcast [4 x i8*]* %A to { [16 x i8] }*            ; <{ [16 x i8] }*> [#uses=1]
        %D = getelementptr { [16 x i8] }* %C, i32 0, i32 0, i32 8               ; <i8*> [#uses=1]
        %E = bitcast i8* %D to i8**             ; <i8**> [#uses=1]
        store i8* %v, i8** %E
        %F = getelementptr [4 x i8*]* %A, i32 0, i32 2          ; <i8**> [#uses=1]
        %G = load i8** %F               ; <i8*> [#uses=1]
        ret i8* %G
}

Doing so would allow SROA to eliminate the alloca, turning the function into an identity function.

-Chris
Comment 1 Chris Lattner 2007-04-27 16:00:32 PDT
working on this.
Comment 2 Chris Lattner 2007-04-27 19:58:38 PDT
Implemented, patch here:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070423/048573.html

Testcase here: Transforms/InstCombine/bitcast-gep.ll

-Chris