Q:

getelementptr has -1 as the first index operand

I'm reading the IR of nginx generated by Clang. In function ngx_event_expire_timers, there are some getelementptr instructions with i64 -1 as first index operand. For example, 
%handler = getelementptr inbounds %struct.ngx_rbtree_node_s, %struct.ngx_rbtree_node_s* %node.addr.0.i, i64 -1, i32 2

I know the first index operand will be used as an offset to the first operand. But what does a negative offset mean?

A:

The GEP instruction is perfectly fine with negative indices. 
In this case you have something like: 
node arr[100]; 
node* ptr = arr[50]; 
if ( (ptr-1)->value == ptr->value) 
  // then ...

GEP with negative indices just calculate the offset to the base pointer into the other direction. There is nothing wrong with it. 

