Skip to content

Commit 4f30aac

Browse files
authored
Vectorizer bug fix: address argument of memory operations (#3446)
Fix bug: use address arg of the first instruction in a group ... not the last! Only matters for arrays at the moment, where the address offset argument is not always the same register.
1 parent cc91e2b commit 4f30aac

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

backend/cfg/vectorize.ml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2873,7 +2873,9 @@ let augment_reg_map reg_map group =
28732873
let add_vector_instructions_for_group reg_map state group ~before:cell
28742874
old_instruction =
28752875
let vector_instructions = Computation.Group.vector_instructions group in
2876-
let key_instruction = Instruction.basic old_instruction in
2876+
let first_instruction =
2877+
Computation.Group.scalar_instructions group |> List.hd
2878+
in
28772879
let new_regs : Reg.t Numbers.Int.Tbl.t = Numbers.Int.Tbl.create 2 in
28782880
let get_new_reg n =
28792881
match Numbers.Int.Tbl.find_opt new_regs n with
@@ -2890,13 +2892,13 @@ let add_vector_instructions_for_group reg_map state group ~before:cell
28902892
match simd_reg with
28912893
| New_Vec128 n -> get_new_reg n
28922894
| Argument n ->
2893-
let original_reg = (Instruction.arguments key_instruction).(n) in
2895+
let original_reg = (Instruction.arguments first_instruction).(n) in
28942896
Substitution.get_reg_exn reg_map original_reg
28952897
| Result n ->
2896-
let original_reg = (Instruction.results key_instruction).(n) in
2898+
let original_reg = (Instruction.results first_instruction).(n) in
28972899
Substitution.get_reg_exn reg_map original_reg
28982900
| Original n ->
2899-
let original_reg = (Instruction.arguments key_instruction).(n) in
2901+
let original_reg = (Instruction.arguments first_instruction).(n) in
29002902
original_reg
29012903
in
29022904
let desc = Cfg.Op simd_instruction.operation in

0 commit comments

Comments
 (0)