Hi, Is it correct to convert, %196 = load i32* %195, align 8 ; <i32> [#uses=1] %197 = zext i32 %196 to i64 ; <i64> [#uses=1] %198 = ptrtoint i8* %193 to i64 ; <i64> [#uses=1] %199 = add i64 %198, %197 ; <i64> [#uses=1] %200 = inttoptr i64 %199 to i8* ; <i8*> [#uses=1] into %200 = getelementptr %193, %196 Reducing the unnecessary casts of converting to integers and then back? Thanks, Arushi -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110404/f7682c3b/attachment.html>
Hi,> > Is it correct to convert, > > %196 = load i32* %195, align 8 ; <i32> [#uses=1] > %197 = zext i32 %196 to i64 ; <i64> [#uses=1] > %198 = ptrtoint i8* %193 to i64 ; <i64> [#uses=1] > %199 = add i64 %198, %197 ; <i64> [#uses=1] > %200 = inttoptr i64 %199 to i8* ; <i8*> [#uses=1] > > into > > %200 = getelementptr %193, %196 > > Reducing the unnecessary casts of converting to integers and then back? > > Thanks, > Arushi > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110404/ec6a8c2c/attachment.html>
On Mon, Apr 4, 2011 at 5:02 PM, Arushi Aggarwal <arushi987 at gmail.com> wrote:> > >> Hi, >> Is it correct to convert, >> %196 = load i32* %195, align 8 ; <i32> [#uses=1] >> %197 = zext i32 %196 to i64 ; <i64> [#uses=1] >> %198 = ptrtoint i8* %193 to i64 ; <i64> [#uses=1] >> %199 = add i64 %198, %197 ; <i64> [#uses=1] >> %200 = inttoptr i64 %199 to i8* ; <i8*> [#uses=1] >> into >> %200 = getelementptr %193, %196 >> Reducing the unnecessary casts of converting to integers and then back? >> Thanks, >> Arushi >>See http://llvm.org/docs/LangRef.html#pointeraliasing ; it's not correct in general. It is correct if %196 isn't dependent on the address of any memory object, though. -Eli