This was split from http://reviews.llvm.org/D7255 and implements the SelectionDAGBuilder parts.
We eagerly canonicalize gep indices to the width of a machine register (i64 on x86_64). To do so, we insert sign extensions (sext) to promote smaller types. This change substitutes zero extensions where we know the value being extended is positive. This is motivated by the fact that zero extensions are generally cheaper on x86.
A TODO here (definitely not this change) could be to exploit the case where you *know* that the high bit is set (i.e. KnownOne == true), and emit a bitwise OR of 0xffff0000 with a zext of the value. I don't know if that will actually be faster, even on x86, but it does remove the data dependence of the higher bits on the sign bit of the source (narrower) value.