Index of /site/clang-as-problem-solving-assistant

      Name                    Last modified      Size  Description
Parent Directory - tests 2022-03-02 07:56 49K tests-O0-opt-pass.ll 2022-03-02 07:56 42K tests-O0.ll 2022-03-02 07:56 42K tests-O3-opt-pass.ll 2022-03-02 07:56 17K tests-O3.ll 2022-03-02 07:56 17K tests.c 2022-03-02 07:56 5.8K README.md 2022-03-02 07:56 1.2K Makefile 2022-03-02 07:56 817 proofs.py 2022-03-02 07:56 358
Can the clang/llvm optimizer be used as a problem solving assistant?

Can clang be used as a problem solving assistant?

Spoiler: No

In this tweet Joe Groff links to this online compiler interface of a collatz conjecture implementation and clang/llvm optimizes it to return true. Its optimization is so aggressive, and perhaps arrogant, it treats the conjecture as settled and returns 1. The conjecture is of course unproven, and tested only up to about 2**68, a small fraction of the __int128_t parameter.

But it raises an interesting question. Could we glean insights to problems by writing solution checkers and observe clang/llvm's optimizer? Proposed workflow:

  1. write a solution checker
  2. compile the solution checker with optimization
  3. measure the complexity of the compiled checker (eg: cyclomatic complexity of the resulting CFG)
  4. propose bits of the solution by hardcoding them in the solution checker, goto 2

If the complexity of the compiled checker reduces, the partial solution is correct. Iterate this process to converge on a solution.

See ./tests.c for the tests and results.


generated from: clang-as-problem-solving-assistant/README.md