[LLVMdev] sinking address computing in CodeGenPrepare

Junbum Lim junbums at gmail.com
Tue Nov 12 08:39:06 PST 2013


Hi All,

In CodeGenPrepare pass,  OptimizeMemoryInst() try to sink  address computing into users' block by converting GET to integers? It appear that it have impacts on ISel's result, but I'm not clear about the main purpose of the transformation. 

FROM :
for.body.lr.ph:
                %zzz = getelementptr inbounds %struct.SS* %a2, i32 0, i32 35    
 
for.body:
                %4 = load double* %zzz, align 8, !tbaa !0
 
TO :
for.body:
  %sunkaddr27 = ptrtoint %struct.SS* %a2 to i32       <----- sink address computing into user's block
  %sunkaddr28 = add i32 %sunkaddr27, 272
  %sunkaddr29 = inttoptr i32 %sunkaddr28 to double*
  %4 = load double* %sunkaddr29, align 8, !tbaa !8


>From what I observed, this transformation can cause poor alias analysis results without using GEP.  So, I want to see there is any way to avoid this conversion.

My question is : 
1. Why do we need to sink address computing into users' block? What is the benefit of this conversion ?  
2. Can we directly use GEP instead of breaking it into integer calculations ? 
 
Thanks,
Jun



More information about the llvm-dev mailing list