Avoid iadd for ptr const val with zero offset
This commit is contained in:
parent
cd2fc77b0e
commit
2f2d3b2fd4
@ -225,10 +225,13 @@ pub(crate) fn trans_const_value<'tcx>(
|
|||||||
}
|
}
|
||||||
None => bug!("missing allocation {:?}", ptr.alloc_id),
|
None => bug!("missing allocation {:?}", ptr.alloc_id),
|
||||||
};
|
};
|
||||||
let val = fx
|
let val = if ptr.offset.bytes() != 0 {
|
||||||
.bcx
|
fx.bcx
|
||||||
.ins()
|
.ins()
|
||||||
.iadd_imm(base_addr, i64::try_from(ptr.offset.bytes()).unwrap());
|
.iadd_imm(base_addr, i64::try_from(ptr.offset.bytes()).unwrap())
|
||||||
|
} else {
|
||||||
|
base_addr
|
||||||
|
};
|
||||||
return CValue::by_val(val, layout);
|
return CValue::by_val(val, layout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user