Bug 43855 - assembly generated labels should use hex instead of decimal
Summary: assembly generated labels should use hex instead of decimal
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.6.0
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: compile-time-hog
Depends on:
Blocks:
 
Reported: 2010-04-22 18:10 UTC by Dan Nicolaescu
Modified: 2021-11-29 08:06 UTC (History)
2 users (show)

See Also:
Host: i686-pc-linux-gnu
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2021-11-28 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dan Nicolaescu 2010-04-22 18:10:34 UTC
Assembly labels are generated like thisL .LDECIMAL_NUMBER
If instead of DECIMAL_NUMBER the hex version of the same number (or even better base 32 or base 64) the total assembly size would be reduced.

For combine.s the file size difference for using hex is %1.5 for -O2 -S (if I remember well)

Here's an emacs function that will estimate the size.  Evaluate the function, open the .s file and do M-x my-estimate, it will show the size savings estimate.

(defun my-estimate ()
  (interactive)
  (let ((crt-size (point-max)))
    (goto-char (point-min))
    (while (re-search-forward "\\([.]L[A-Z]*\\)\\([0-9]+\\)" nil t)
      (replace-match (format "%s%x" (match-string 1) (string-to-number (match-string 2))) nil nil))
    (message "Size %% change = %f" (/ (* 100.0 (- (point-max) crt-size)) (point-max)))))

This is a rather simple minded estimate, but it shouldn't bet too far.
Things like .LBB and .LBE need to be considered carefully.
This should help speed up the assembler a bit...
Comment 1 Andrew Pinski 2016-08-14 18:52:42 UTC
Confirmed.
Comment 2 Andrew Pinski 2021-11-29 08:06:30 UTC
https://gcc.gnu.org/pipermail/gcc-patches/2011-October/327058.html

Did improve the performance slightly on the compile side but really I think there is more if we use hex rather than digits on both sides.