Skip to content

Commit

Permalink
Revert "Canonicalize GEPs"
Browse files Browse the repository at this point in the history
This reverts commit 23cc55f.
  • Loading branch information
DianQK committed Dec 11, 2024
1 parent b84448f commit 2547971
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 21 deletions.
16 changes: 4 additions & 12 deletions compiler/rustc_codegen_ssa/src/mir/place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,18 +422,10 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
layout.size
};

let llval = {
let pointee_layout = layout;
let bytes = pointee_layout.size.align_to(pointee_layout.align.abi).bytes();
let rhs = if bytes == 1 {
llindex
} else {
let lhs = llindex;
let rhs = bx.cx().const_usize(bytes);
bx.unchecked_umul(lhs, rhs)
};
bx.inbounds_ptradd(self.val.llval, rhs)
};
let llval = bx.inbounds_gep(bx.cx().backend_type(self.layout), self.val.llval, &[
bx.cx().const_usize(0),
llindex,
]);
let align = self.val.align.restrict_for_offset(offset);
PlaceValue::new_sized(llval, align).with_type(layout)
}
Expand Down
11 changes: 2 additions & 9 deletions compiler/rustc_codegen_ssa/src/mir/rvalue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -925,15 +925,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
// so offsetting a pointer to ZST is a noop.
lhs
} else {
let bytes = pointee_layout.size.align_to(pointee_layout.align.abi).bytes();
let rhs = if bytes == 1 {
rhs
} else {
let lhs = rhs;
let rhs = bx.cx().const_usize(bytes);
bx.unchecked_umul(lhs, rhs)
};
bx.inbounds_ptradd(lhs, rhs)
let llty = bx.cx().backend_type(pointee_layout);
bx.inbounds_gep(llty, lhs, &[rhs])
}
}
mir::BinOp::Shl | mir::BinOp::ShlUnchecked => {
Expand Down

0 comments on commit 2547971

Please sign in to comment.