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

    <tr>
        <th>Summary</th>
        <td>
            [clang/c++] Very strange/bad optimizer behavior.
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          no-more-secrets
      </td>
    </tr>
</table>

<pre>
    Problem demo: https://godbolt.org/z/zfMohEMj7

The "good" variant produces perfectly optimized code, while the nearly-identical "bad" variant produces a giant explosion of seemingly unoptimized code.

```c++
static int len( char const* input ) {
  return std::string( input ).size();
}

int test() {
  return
    #ifdef GOOD
 len( "h" ) + len( "h" );
    #else /*BAD*/
      len( "h" ) + len( "" );
    #endif
}
```

This (regression?) happened between Clang versions 13 and 14: https://godbolt.org/z/brhYEK4Eh

The problem does not exist in gcc: https://godbolt.org/z/Ed6z6j61a
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVMGOozgQ_ZriUkoUCkLgwCE9afawGs0eVivt0dgFuGVsZJueTX_9ykySnWn1akYyIEpV7xWvXiFC0KNlbuH4BMdLJtY4Od9at5ud511g6TmGrHfq2v7hXW94RsWzg-KMU4xLgOIM1AF1o1O9M3Hv_AjUvaVr-Oym588vJzhc4HD-dv9zYgSi0TkFRPgqvBY24uKdWiUHXNgPLKO5oluinvUbK5ROMdAn_DppwxgnRsvCm-tOK7ZRS2ESZC8-RhQ4bgH-ZzEuaGfRDRiYZ21Hc8XV_ki0_75bqA7fjgR6SmeLhiiilqhtRMMWqEY5CY_S2RCBzqjtskYEahBOtxJEz3H1FkNUSbLiHKLXdkzFj_R90G8MVAM1UNwK4XT5vqHEGTnR1B_i398QgQo9KB7wty9fbhD3boFoSlJtCPT0QfhBf0NiE9LYOqDz0_kCtM38kYA_B_4_XKv08P5D75r_aBsdEKj2PHoOaYpQdIlmEsvClhX2HL8yW_xkhB3xlX1KCpgXKKzCvPwVx_Z--vv59_J5eu_Y5W59xwGtS2bSIaK2OEr5K8jPqnqrXqpcZKotVFM0IuM2P-VFXdRFecqmtsyppEYMR1lX_bGWQzUIJRTlDeVFM1SZbulA5aGk4kA50WnPx14eJStRcSUbIigPPAtt9sa8zok70yGs3NZN1TSZET2bsO05kUwipbEcL5lvU_6uX8cA5cHoEMN_CFFHs_0cbhXdfRGOF_yL_RVD9MKOnMQT6rGzHnuexKt2fp-t3rTv5NFxWvu9dDNQl6huj93i3QvLCNRtnQegbmv-3wAAAP__XCti3g">