[LLVMdev] Question on Load and GetElementPtr instructions

Xiaolong Tang xiaolong.snake at gmail.com
Fri Jun 18 04:54:45 PDT 2010


Considering the following instruction:

  %20 = load %struct.Node** getelementptr inbounds (%struct.Node*
          @head, i32 0, i32 0), align 16 ; <%struct.Node*> [#uses=1]

What is the type of the first operand of the instruction (i.e.,

I thought the operand is a "GetElementPtr" instruction, however, the
predicate "isa<Instruction>()" over the operand returns false.
So, I am confused. Can someone clarify the above instruction for me? 

By the way, why does not LLVM factor out the operand and instead
generate such two instructions: 

  %19 = getelementptr inbounds (%struct.Node* @head, i32 0, i32 0)
  %20 = load %struct.Node** %19, align 16 ; <%struct.Node*> [#uses=1]
What it the cause?  What are the differences between the
"GetElementPtr inbounds" instruction and just the "GetElementPtr"


More information about the llvm-dev mailing list