<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META content="MSHTML 6.00.3790.4186" name=GENERATOR></HEAD>
<BODY><FONT face=Verdana><FONT size=2>
<DIV>I am a newbie to LLVM, so I have to say sorry if I asked the question in
the wrong place.</DIV>
<DIV>In some cases when I generate LLVM IR from machine assembly(with limited
type information) I have to convert the pointers to I32, after the standard
mem2reg pass there still are things like:</DIV>
<DIV> </DIV>
<DIV>inttoptr i32 %1 to i8*</DIV>
<DIV> </DIV>
<DIV>While in fact this can be replaced by the I8* operations, because the I8*
can be unsigned compared, and get rid of the redundant Instrs, Is there any
pass</DIV>
<DIV>can do this, or is there any tricks to avoid these redundant conversions
while retain the meaning of the program?</DIV>
<DIV><BR>define i8* @tag_on(i8* %ptr, i8* %end, i8 %tag)
{<BR>Entry:<BR> ptrtoint i8* %end to
i32
; <i32>:0 [#uses=2]<BR> ptrtoint
i8* %ptr to
i32
; <i32>:1 [#uses=4]<BR> icmp ugt
i32 %0,
%1 ;
<i1>:2 [#uses=1]<BR> br i1 %2,
label %B1, label %B2</DIV>
<DIV> </DIV>
<DIV>B1:
; preds = %Entry<BR> inttoptr i32 %1
to i8* ; <i8*>:3
[#uses=1]<BR> store i8 1, i8*
%3<BR> add i32 %1,
1 ; <i32>:4
[#uses=1]<BR> br label %B2</DIV>
<DIV> </DIV>
<DIV>B2:
; preds = %Entry, %B1<BR> %eax.0 = phi
i32 [ %4, %B1 ], [ %1, %Entry
] ;
<i32> [#uses=4]<BR> icmp ugt i32
%0, %eax.0 ; <i1>:5
[#uses=1]<BR> br i1 %5, label %B3,
label %exit</DIV>
<DIV> </DIV>
<DIV>B3:
; preds = %B2<BR> inttoptr i32 %eax.0
to
i8*
; <i8*>:6 [#uses=1]<BR> store i8
1, i8* %6<BR> add i32 %eax.0,
1
; <i32>:7 [#uses=1]<BR> br label
%exit</DIV>
<DIV> </DIV>
<DIV>exit: ; preds =
%B2, %B3<BR> %eax.1 = phi i32 [ %7,
%B3 ], [ %eax.0, %B2
] ; <i32>
[#uses=1]<BR> inttoptr i32 %eax.1 to
i8*
; <i8*>:8 [#uses=1]<BR> ret i8*
%8<BR>}</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV align=left><FONT size=2>
<HR style="WIDTH: 122px; HEIGHT: 2px" SIZE=2>
</FONT></DIV>
<DIV><FONT color=#c0c0c0><FONT size=2>humeafo</FONT></DIV>
<DIV><FONT size=2>2008-01-22</FONT></FONT></DIV></FONT></BODY></HTML>