Skip to content

Commit

Permalink
Limit CSE of integer constants (#10615)
Browse files Browse the repository at this point in the history
Never do CSE for constants that fit in 32 bits signed.

Do it only for constants that do not fit, and only on some 64-bit targets
where the code generated for Iconst_int can be costly (ARM64, POWER, RISC-V).

Fixes: #10591
  • Loading branch information
xavierleroy committed Sep 9, 2021
1 parent b8efbfb commit 9410b9c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
5 changes: 5 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ Working version
parameter passing on PowerPC (16 registers) and on s390x (8 registers).
(Xavier Leroy, review by Mark Shinwell)

- #10591, #10615: Tune the heuristic for CSE of integer constants
so as to avoid excessive CSE on compiler-generated constants
and long register allocation times.
(Xavier Leroy, report by Edwin Török, review by Nicolás Ojeda Bär)

### Standard library:

* #7812, #10475: `Filename.chop_suffix name suff` now checks that `suff`
Expand Down
5 changes: 0 additions & 5 deletions asmcomp/arm/CSE.ml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ method! class_of_operation op =
| Ispecific _ -> Op_pure
| _ -> super#class_of_operation op

method! is_cheap_operation op =
match op with
| Iconst_int n -> n <= 255n && n >= 0n
| _ -> false

end

let fundecl f =
Expand Down
2 changes: 1 addition & 1 deletion asmcomp/arm64/CSE.ml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ method! class_of_operation op =

method! is_cheap_operation op =
match op with
| Iconst_int n -> n <= 65535n && n >= 0n
| Iconst_int n -> n <= 0x7FFF_FFFFn && n >= -0x8000_0000n
| _ -> false

end
Expand Down
2 changes: 1 addition & 1 deletion asmcomp/power/CSE.ml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ method! class_of_operation op =

method! is_cheap_operation op =
match op with
| Iconst_int n -> n <= 32767n && n >= -32768n
| Iconst_int n -> n <= 0x7FFF_FFFFn && n >= -0x8000_0000n
| _ -> false

end
Expand Down
2 changes: 1 addition & 1 deletion asmcomp/riscv/CSE.ml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ method! class_of_operation op =

method! is_cheap_operation op =
match op with
| Iconst_int n -> n <= 0x7FFn && n >= -0x800n
| Iconst_int n -> n <= 0x7FFF_FFFFn && n >= -0x8000_0000n
| _ -> false

end
Expand Down

0 comments on commit 9410b9c

Please sign in to comment.