This instcombine rule is created to fold away trunc operations that are generated for partial loads. The trunc can be folded away when the value for partial load is available from a prior store or load.
This kind of code can be generated as a result of GVN widening or in some source code as well. The current rule considers partial loads/stores of the form:
%pload = load i8, i8* %a, align 2 %wide.load = load i16, i16* %0, align 2 %lowhalf.1 = trunc i16 %wide.load to i8 call void @consume(i8 %lowhalf.1) call void @consume(i8 %pload).
The store partially feeding into load is added as a test case.
Nit: newer code does not repeat the function name before comments.