Plays/Coding & Dev

PlayChatGPT

Have ChatGPT find a faster version of a hand-tuned assembly routine, with the cycle math

Dave Plummer, the former Microsoft engineer behind Windows Task Manager, asked ChatGPT to optimize a memcpy they wrote for the Motorola 68000.

Reported by @davepl1968on x.com

A prompt to try

Make this routine faster without changing its behavior.

Target: [CPU or runtime, e.g. MC68000, x86-64, Node 22]
Routine:
[paste code with its comments]

1. Explain where the time goes now, with cycle counts or cost estimates per loop.
2. Propose a faster version and show the same math for it.
3. Give the speedup for small, medium and large inputs, and list any cases where the new version is slower or uses more memory or code space.
4. Write tests covering edge cases (empty input, odd alignment, boundaries) that I can run on both versions.
5. Say clearly what you calculated versus what would need real measurement.

Fill in anything in [brackets] before you send it. Anything that spends money, sends a message or signs something should stay behind your own approval.

How it went, step by step

  1. 01Paste the routine with its comments and say which CPU or runtime it targets.
  2. 02Ask for a faster version and for the cost math (cycles, instructions or benchmarks) for both versions.
  3. 03Ask it to list the input sizes or cases where the new version is slower.
  4. 04Ask how it checked correctness, then assemble, test and benchmark it yourself on real hardware.
Read the original source Discuss in the forum