Skip to content

Commit e99f6f4

Browse files
eddybLegNeato
authored andcommitted
builder: struct_gep implies inbounds.
1 parent bb0e605 commit e99f6f4

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed

crates/rustc_codegen_spirv/src/builder/builder_methods.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
431431
.map(|idx| self.constant_u32(self.span(), idx).def(self))
432432
.collect::<Vec<_>>();
433433
self.emit()
434-
.access_chain(leaf_ptr_ty, None, ptr.def(self), indices)
434+
.in_bounds_access_chain(leaf_ptr_ty, None, ptr.def(self), indices)
435435
.unwrap()
436436
.with_type(leaf_ptr_ty)
437437
};
@@ -1417,7 +1417,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
14171417
.collect::<Vec<_>>();
14181418
return self
14191419
.emit()
1420-
.access_chain(result_type, None, original_ptr, indices)
1420+
.in_bounds_access_chain(result_type, None, original_ptr, indices)
14211421
.unwrap()
14221422
.with_type(result_type);
14231423
}
@@ -1435,7 +1435,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
14351435
}
14361436
let index_const = self.constant_u32(self.span(), idx as u32).def(self);
14371437
self.emit()
1438-
.access_chain(
1438+
.in_bounds_access_chain(
14391439
result_type,
14401440
None,
14411441
ptr.def(self),
@@ -1744,7 +1744,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
17441744
.map(|idx| self.constant_u32(self.span(), idx).def(self))
17451745
.collect::<Vec<_>>();
17461746
self.emit()
1747-
.access_chain(dest_ty, None, ptr.def(self), indices)
1747+
.in_bounds_access_chain(dest_ty, None, ptr.def(self), indices)
17481748
.unwrap()
17491749
.with_type(dest_ty)
17501750
} else {
@@ -2683,7 +2683,6 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
26832683
enum Inst<'tcx, ID> {
26842684
Bitcast(ID, ID),
26852685
CompositeExtract(ID, ID, u32),
2686-
AccessChain(ID, ID, SpirvConst<'tcx, 'tcx>),
26872686
InBoundsAccessChain(ID, ID, SpirvConst<'tcx, 'tcx>),
26882687
Store(ID, ID),
26892688
Load(ID, ID),
@@ -2721,9 +2720,6 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
27212720
Some(
27222721
match (inst.class.opcode, inst.result_id, &id_operands[..]) {
27232722
(Op::Bitcast, Some(r), &[x]) => Inst::Bitcast(r, x),
2724-
(Op::AccessChain, Some(r), &[p, i]) => {
2725-
Inst::AccessChain(r, p, self.builder.lookup_const_by_id(i)?)
2726-
}
27272723
(Op::InBoundsAccessChain, Some(r), &[p, i]) => {
27282724
Inst::InBoundsAccessChain(
27292725
r,
@@ -2887,9 +2883,9 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
28872883
array_base_ptr,
28882884
SpirvConst::U32(array_idx),
28892885
),
2890-
Inst::AccessChain(a_ptr, a_base_ptr, SpirvConst::U32(0)),
2886+
Inst::InBoundsAccessChain(a_ptr, a_base_ptr, SpirvConst::U32(0)),
28912887
Inst::Store(a_st_dst, a_st_val),
2892-
Inst::AccessChain(b_ptr, b_base_ptr, SpirvConst::U32(1)),
2888+
Inst::InBoundsAccessChain(b_ptr, b_base_ptr, SpirvConst::U32(1)),
28932889
Inst::Store(b_st_dst, b_st_val),
28942890
] if array_base_ptr == rt_args_array_ptr_id
28952891
&& array_idx as usize == rt_arg_idx

tests/ui/dis/index_user_dst.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
%1 = OpFunction %2 None %3
22
%4 = OpLabel
33
OpLine %5 9 12
4-
%6 = OpAccessChain %7 %8 %9
4+
%6 = OpInBoundsAccessChain %7 %8 %9
55
%10 = OpArrayLength %11 %8 0
66
OpLine %5 10 21
77
%12 = OpULessThan %13 %9 %10

tests/ui/dis/issue-1062.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ OpLine %11 1145 4
2020
%28 = OpIEqual %20 %23 %21
2121
%29 = OpSelect %7 %28 %6 %27
2222
OpLine %5 12 4
23-
%30 = OpAccessChain %31 %32 %21
23+
%30 = OpInBoundsAccessChain %31 %32 %21
2424
OpStore %30 %22
25-
%33 = OpAccessChain %31 %32 %34
25+
%33 = OpInBoundsAccessChain %31 %32 %34
2626
OpStore %33 %29
2727
OpNoLine
2828
OpReturn

0 commit comments

Comments
 (0)