<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Dead Code Elimination Regression at -O3 (trunk vs 13.0.0)"
   href="https://bugs.llvm.org/show_bug.cgi?id=52078">52078</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Dead Code Elimination Regression at -O3  (trunk vs 13.0.0)
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>theodoros.theodoridis@inf.ethz.ch
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>cat case.c   
static int b = -1, e = 1;
static short c, d;
void foo(void);
short a(unsigned short f, int g) { return f >> g; }
int main() {
  c++;
  d = a(4294967295 + (c > 0), 1);
  e ^= (short)(d * 3) / (unsigned)b;
  if (!e)
    foo();
}

trunk can no longer eliminate foo and it generates more complicated code:

clang-13 -v 
clang version 13.0.0 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
d7b669b3a30345cfcdb2fde2af6f48aa4b94845d)
Target: x86_64-unknown-linux-gnu

clang-13 -S case.c -O3 -o /dev/stdout   
...
main:                                   # @main
        .cfi_startproc
# %bb.0:
        addw    $1, c(%rip)
        xorl    %eax, %eax
        retq

clang-trunk -v      
clang version 14.0.0 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
424733c12aacc227a28114deba72061153f8dff2)
Target: x86_64-unknown-linux-gnu

clang-trunk -S case.c -O3 -o /dev/stdout 
...
main:                                   # @main
        .cfi_startproc
# %bb.0:
        pushq   %rax
        .cfi_def_cfa_offset 16
        movzwl  c(%rip), %eax
        leal    1(%rax), %ecx
        movw    %cx, c(%rip)
        xorl    %ecx, %ecx
        cmpl    $32767, %eax                    # imm = 0x7FFF
        adcl    $-1, %ecx
        movzwl  %cx, %eax
        shrl    %eax
        leal    (%rax,%rax,2), %eax
        xorl    %ecx, %ecx
        cmpw    $-1, %ax
        sete    %cl
        xorl    %ecx, e(%rip)
        je      .LBB1_1
# %bb.2:
        xorl    %eax, %eax
        popq    %rcx
        .cfi_def_cfa_offset 8
        retq
.LBB1_1:
        .cfi_def_cfa_offset 16
        callq   foo
        xorl    %eax, %eax
        popq    %rcx
        .cfi_def_cfa_offset 8
        retq

commit cfb6dfcbd13b417f83d8adca69b60ba4254b4233 introduced this regression</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>