Usually the case where the types are the same ends up being handled
fine because it's legal to do a trivial bitcast to the same type.
However, this is not true for aggregate types. Short-circuit the
whole code if the types match exactly to account for this.
const DataLayout &DL) {
do {
Type *SrcTy = C->getType();
+ if (SrcTy == DestTy)
+ return C;
+
TypeSize DestSize = DL.getTypeSizeInBits(DestTy);
TypeSize SrcSize = DL.getTypeSizeInBits(SrcTy);
if (!TypeSize::isKnownGE(SrcSize, DestSize))
define { i64, i64 } @test_load_struct() {
; CHECK-LABEL: @test_load_struct(
-; CHECK-NEXT: [[V:%.*]] = load { i64, i64 }, { i64, i64 }* @g3, align 8
-; CHECK-NEXT: ret { i64, i64 } [[V]]
+; CHECK-NEXT: ret { i64, i64 } { i64 123, i64 112312312 }
;
%v = load { i64, i64 }, { i64, i64 }* @g3
ret { i64, i64 } %v