<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: arial,helvetica,sans-serif; font-size: 10pt; color: #000000'>Hi Nick,<br><br>We really don't do AA on inttoptr at all. You should use i8* (or some other appropriate pointer type) and GEPs instead.<br><br> -Hal<br><br><hr id="zwchr"><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px; color: rgb(0, 0, 0); font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><b>From: </b>"Peet Nick via llvm-dev" <llvm-dev@lists.llvm.org><br><b>To: </b>llvm-dev@lists.llvm.org<br><b>Sent: </b>Monday, July 4, 2016 11:05:11 AM<br><b>Subject: </b>[llvm-dev] Optimization issues (Alias Analysis?)<br><br><div dir="ltr">Hey,<div><br></div><div>I am currently working on a VM which is based on LLVM and I would like to use its optimizer, but it somehow it can't detect something very simple (I guess.)</div><div><br></div><div>This is the LLVM IR:</div><div><br></div><div><div>target datalayout = "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128"</div><div>target triple = "i386-unknown-linux-gnu"</div><div><br></div><div>%struct.regs = type { i32, i32, i32 }</div><div><br></div><div>define void @Test(%struct.regs* noalias nocapture sret, i32, i32, i32) local_unnamed_addr #0 {</div><div>  %5 = add i32 %3, -4</div><div>  %6 = inttoptr i32 %5 to i32*</div><div>  store i32 %2, i32* %6, align 4</div><div>  </div><div>  %7 = add i32 %3, -8</div><div>  %8 = inttoptr i32 %7 to i32*</div><div>  store i32 %1, i32* %8, align 4</div><div>  </div><div>  %9 = load i32, i32* %6, align 4</div><div>  </div><div>  %.sroa.0.0..sroa_idx = getelementptr inbounds %struct.regs, %struct.regs* %0, i32 0, i32 0</div><div>  store i32 %9, i32* %.sroa.0.0..sroa_idx, align 4</div><div>  </div><div>  %.sroa.4.0..sroa_idx4 = getelementptr inbounds %struct.regs, %struct.regs* %0, i32 0, i32 1</div><div>  store i32 %1, i32* %.sroa.4.0..sroa_idx4, align 4</div><div>  </div><div>  %.sroa.7.0..sroa_idx5 = getelementptr inbounds %struct.regs, %struct.regs* %0, i32 0, i32 2</div><div>  store i32 %3, i32* %.sroa.7.0..sroa_idx5, align 4</div><div>  </div><div>  ret void</div><div>}</div></div><div><br></div><div>This is compiled from some cpp just to reproduce the issue.</div><div>The issue here is that the load isn't eliminated and that the third store isn't directly using %2.</div><div><br></div><div>I thought that this might be an issue with the current BasicAliasAnalysis so I also tried CFL which isn't working either.</div><div><br></div><div>~ Nick </div></div>
<br>_______________________________________________<br>LLVM Developers mailing list<br>llvm-dev@lists.llvm.org<br>http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev<br></blockquote><br><br><br>-- <br><div><span name="x"></span>Hal Finkel<br>Assistant Computational Scientist<br>Leadership Computing Facility<br>Argonne National Laboratory<span name="x"></span><br></div></div></body></html>