<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/117992>117992</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            <clang> Unusual Compilation Speed of `-O1`
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          ADDALBA
      </td>
    </tr>
</table>

<pre>
    ## **Unusual Compilation Speed of `-O1`**

During testing with Clang 14.0.6 and Clang 9.0.1, we observed that in certain test cases, the compilation speed with `-O1` was very close to that of `-O2` or `-Ofast`, and in some cases even slower. Due to limited resources, we reported only consistently observed anomalies and could not entirely rule out random factors. The Docker image used for testing is available [here](https://hub.docker.com/r/anonymicse2021/gcc_inputs). Clang was installed using `llvm.sh`. Detailed test results are as follows:

### **Test Details**

```bash
# Test Case: linear-algebra/kernels/bicg
time clang-14 -Ofast -I ./inputs/utilities -I ./inputs/linear-algebra/kernels/bicg ./inputs/utilities/polybench.c ./inputs/linear-algebra/kernels/bicg/bicg.c -DPOLYBENCH_TIME -o ./test
real    0m0.171s
user    0m0.115s
sys 0m0.055s

time clang-14 -O1 -I ./inputs/utilities -I ./inputs/linear-algebra/kernels/bicg ./inputs/utilities/polybench.c ./inputs/linear-algebra/kernels/bicg/bicg.c -DPOLYBENCH_TIME -o ./test
real 0m0.178s
user    0m0.125s
sys     0m0.053s

time clang-9 -Ofast -I ./inputs/utilities -I ./inputs/linear-algebra/kernels/bicg ./inputs/utilities/polybench.c ./inputs/linear-algebra/kernels/bicg/bicg.c -DPOLYBENCH_TIME -o ./test
real    0m0.148s
user    0m0.100s
sys 0m0.048s

time clang-9 -O1 -I ./inputs/utilities -I ./inputs/linear-algebra/kernels/bicg ./inputs/utilities/polybench.c ./inputs/linear-algebra/kernels/bicg/bicg.c -DPOLYBENCH_TIME -o ./test
real 0m0.153s
user    0m0.104s
sys     0m0.047s

# Test Case: linear-algebra/kernels/gemm
time clang-14 -O2 -I ./inputs/utilities -I ./inputs/linear-algebra/kernels/gemm ./inputs/utilities/polybench.c ./inputs/linear-algebra/kernels/gemm/gemm.c -DPOLYBENCH_TIME -o ./test
real 0m0.189s
user    0m0.125s
sys     0m0.064s

time clang-14 -O1 -I ./inputs/utilities -I ./inputs/linear-algebra/kernels/gemm ./inputs/utilities/polybench.c ./inputs/linear-algebra/kernels/gemm/gemm.c -DPOLYBENCH_TIME -o ./test
real    0m0.194s
user    0m0.132s
sys 0m0.063s

time clang-9 -O2 -I ./inputs/utilities -I ./inputs/linear-algebra/kernels/gemm ./inputs/utilities/polybench.c ./inputs/linear-algebra/kernels/gemm/gemm.c -DPOLYBENCH_TIME -o ./test
real 0m0.152s
user    0m0.107s
sys     0m0.045s

time clang-9 -O1 -I ./inputs/utilities -I ./inputs/linear-algebra/kernels/gemm ./inputs/utilities/polybench.c ./inputs/linear-algebra/kernels/gemm/gemm.c -DPOLYBENCH_TIME -o ./test
real    0m0.156s
user    0m0.112s
sys 0m0.044s
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcV02P2zYQ_TX0ZWCBpD5sHXTw2jEaIG0KND30FFDSSGJDkQaHsuF_X1Da3WTrDboBtkCwgACCX29m3jyOSEWke4tYsfyO5YeVmsLgfLU7HHYf7nar2rXXismUyRSY3DG5-9NONCkDezeetFFBOwt_nBBbcB2wgq8_ClbwZS3j8TtMXtseAlKI7UWHAfZG2R5ElvCkAGXb-4Ey4Ylgcg8XBFcT-jO2EAYVQFto0Ael7QwEjSKkuDIMCM03vtDsy2zk0Ru4KIIz-is0xhFCcAvog8cyrnF-6XSKwhzBfnZMWyA34mIQ8IwWyLgL-gQO0wxl9KgDtuCR3OSbxa0LgseT83HCWXOFxlnSFNAGc_0am7JuVEYjzbYaN5kWrAuANmiP5gp-MghuCuCVbd0InWqC85TApwHh4Jov6EGPqkeYCFvonH8kWhOos9JG1QaB5Xc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