the generation of getelementptr instruction

Hi all,
I’m reading the language reference of LLVM here: http://llvm.org/docs/LangRef.html#i_getelementptr

In the first example, it shows that the generated IR is supposed to be something like:

%reg = getelementptr %ST* %s, i32 1, i32 2, i32 1, i32 5, i32 13

But when I copied the code and compile it myself (using v2.7), I got five getelementptr instructions, which are just like the equivalent code given later in the document. 
In the case above, why the resulting IRs are different? 
Thanks a lot.
 
Regards,
--Wenbin

Just a quirk of frontend code generation; you'll get the shown result with -O.

-Eli

Hi Wenbin,

I'm reading the language reference of LLVM here:
LLVM Language Reference Manual — LLVM 18.0.0git documentation

In the first example, it shows that the generated IR is supposed to be
something like:
%reg = getelementptr %ST* %s, i32 1, i32 2, i32 1, i32 5, i32 13
But when I copied the code and compile it myself (using v2.7), I got
five getelementptr instructions, which are just like the equivalent
code given later in the document. In the case above, why the
resulting IRs are different?

if you enable optimizations in the frontend (-O1), the resulting LLVM
code will look just as shown in the example.

Regards,
Christoph