Auto merge of #134117 - DianQK:gep-i8, r=oli-obk
Modifies the index instruction from `gep [0 x %Type]` to `gep %Type` Fixes #133979. This PR modifies the index instruction from `gep [0 x %Type]` to `gep %Type`, which is the same with pointer offset calculation. This will help LLVM calculate various formats of GEP instructions. According to [[RFC] Replacing getelementptr with ptradd](https://discourse.llvm.org/t/rfc-replacing-getelementptr-with-ptradd/68699), we ultimately aim to canonicalize everything to `gep i8`. Based on the results from https://github.com/rust-lang/rust/pull/134117#issuecomment-2531717076, I think we still need to investigate some missing optimizations, so this PR is just a small step forward. r? compiler
This commit is contained in:
commit
a611773d80
3 changed files with 60 additions and 4 deletions
|
@ -422,10 +422,7 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
|
|||
layout.size
|
||||
};
|
||||
|
||||
let llval = bx.inbounds_gep(bx.cx().backend_type(self.layout), self.val.llval, &[
|
||||
bx.cx().const_usize(0),
|
||||
llindex,
|
||||
]);
|
||||
let llval = bx.inbounds_gep(bx.cx().backend_type(layout), self.val.llval, &[llindex]);
|
||||
let align = self.val.align.restrict_for_offset(offset);
|
||||
PlaceValue::new_sized(llval, align).with_type(layout)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue