[llvm-dev] Instruction selection for 'load' based on static vs. dynamic data

陳韋任 via llvm-dev llvm-dev at lists.llvm.org
Mon May 8 07:03:37 PDT 2017


>
> To give a concrete example, here's an LLVM IR snippet that should be
> lowered to 'lpm':
>
>     @switch.table = private unnamed_addr constant [15 x i8]
> c"\01\01\01\01\01\00\00\00\00\00\00\00\00\00\01"
>
>     switch.lookup:                                    ; preds = %start
>       %2 = sext i8 %0 to i16
>       %switch.gep = getelementptr inbounds [15 x i8], [15 x i8]*
> @switch.table, i16 0, i16 %2
>       %switch.load = load i8, i8* %switch.gep, align 1
>       br label %bb8
>
> and here's one that should be lowered to 'ld':
>
>     %S = type { i8 }
>
>     start:
>       %1 = getelementptr inbounds %S, %S* %0, i16 0, i32 0
>       %2 = load i8, i8* %1, align 1
>       ret i8 %2
>     }
>
> So my question is, what kind of pattern matching can I do in my 'lpm'
> and 'ld' instructions that it would be able to make a distinction
> about these two usecases?


​I can only think of examining the load operand, which is a result of
getelementptr​. Then check the second
argument of getelementptr​ (%0 or @switch.table).

Maybe Leslie (cc'ed) can answer this question.

-- 
Wei-Ren Chen (陳韋任)
Homepage: https://people.cs.nctu.edu.tw/~chenwj
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170508/c6b2d06a/attachment.html>


More information about the llvm-dev mailing list