<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">To give a concrete example, here's an LLVM IR snippet that should be<br>
lowered to 'lpm':<br>
<br>
    @switch.table = private unnamed_addr constant [15 x i8] c"\01\01\01\01\01\00\00\00\00\<wbr>00\00\00\00\00\01"<br>
<br>
    switch.lookup:                                    ; preds = %start<br>
      %2 = sext i8 %0 to i16<br>
      %switch.gep = getelementptr inbounds [15 x i8], [15 x i8]* @switch.table, i16 0, i16 %2<br>
      %switch.load = load i8, i8* %switch.gep, align 1<br>
      br label %bb8<br>
<br>
and here's one that should be lowered to 'ld':<br>
<br>
    %S = type { i8 }<br>
<br>
    start:<br>
      %1 = getelementptr inbounds %S, %S* %0, i16 0, i32 0<br>
      %2 = load i8, i8* %1, align 1<br>
      ret i8 %2<br>
    }<br>
<br>
So my question is, what kind of pattern matching can I do in my 'lpm'<br>
and 'ld' instructions that it would be able to make a distinction<br>
about these two usecases?</blockquote><div><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">​I can only think of examining the load operand, which is a result of getelementptr​. Then check the second</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">argument of getelementptr​ (%0 or <span style="font-family:arial,sans-serif">@switch.table</span>).</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Maybe <span style="color:rgb(0,0,0);font-size:14px;font-family:arial,sans-serif">Leslie (cc'ed) can answer this question.</span></div></div><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div>Wei-Ren Chen (陳韋任)<br>Homepage: <a href="https://people.cs.nctu.edu.tw/~chenwj" target="_blank">https://people.cs.nctu.edu.tw/~chenwj</a></div></div></div>
</div></div>