mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-16 04:55:22 +03:00
Avoid iadd for ptr const val with zero offset
This commit is contained in:
+7
-4
@@ -225,10 +225,13 @@ pub(crate) fn trans_const_value<'tcx>(
|
||||
}
|
||||
None => bug!("missing allocation {:?}", ptr.alloc_id),
|
||||
};
|
||||
let val = fx
|
||||
.bcx
|
||||
.ins()
|
||||
.iadd_imm(base_addr, i64::try_from(ptr.offset.bytes()).unwrap());
|
||||
let val = if ptr.offset.bytes() != 0 {
|
||||
fx.bcx
|
||||
.ins()
|
||||
.iadd_imm(base_addr, i64::try_from(ptr.offset.bytes()).unwrap())
|
||||
} else {
|
||||
base_addr
|
||||
};
|
||||
return CValue::by_val(val, layout);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user