<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 --- - more optimize oppotunity" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D23672&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=1HK7fv9cCVfwIcLqQ470nFiz716aNqthESiQ2y1f8HU&s=09JsKWxizidJwILj4Xnzid11gY7Qv2zxEzCZCNUM-aw&e=">23672</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>more optimize oppotunity
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>ishiura-compiler@ml.kwansei.ac.jp
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>We compiled a program (A.c) by LLVM/Clang-3.7.0 and GCC-6.0.0 with -O3 option.
Although Clang/LLVM performed better optimization on this code (idvil is
eliminated), 
the three instructions (incl, cmpl, jae) for BB#1 look totally useless and we
wonder why they could not be deleted.

(A.c)
int x = 1;

int main (void)
{
    int t = 1/x;

    if (t == 1) ;
    else __builtin_abort();

  return 0;
}

+------------------------------------------------------------+--------------------------------------------------------+
|                 gcc.s (gcc A.c -O3 -S)                     |             
clang.s (clang A.c -O3 -S)                |
+------------------------------------------------------------+--------------------------------------------------------+
|main:                                                       |                 
                                      *
|.LFB11:                                                     |main:            
                      # @main         *
|        .cfi_startproc                                      |       
.cfi_startproc                                  |
|        movl  $1, %eax                                      |# BB#0:          
                      # %entry        *
|        cltd                                                |                 
                                      |
|        idivl   x1638(%rip)                                 |                 
                                      |
|        cmpl    $1, %eax                                    |                 
                                      |
|        jne     .L5                                         |                 
                                      |
|        xorl    %eax, %eax                                  |                 
                                      |
|        ret                                                 |                 
                                      |
|.L5:                                                        |                 
                                      |
|        pushq   %rax                                        |        pushq  
%rax                                    |
|                                                            |.Ltmp0:          
                                      *
|        .cfi_def_cfa_offset 16                              |       
.cfi_def_cfa_offset 16                          |
|        call    abort                                       |        movl   
x1638(%rip), %eax                       *
|                                                            |        cmpl   
$1, %eax                                *
|                                                            |        jne    
.LBB0_3                                 *
|                                                            |# BB#1:          
                      # %entry        *
|                                                            |        incl   
%eax                    # <--HERE       *
|                                                            |        cmpl   
$3, %eax                # <--HERE       *
|                                                            |        jae    
.LBB0_3                 # <--HERE       *
|                                                            |# BB#2:          
                      # %if.end       *
|                                                            |        xorl   
%eax, %eax                              *
|                                                            |        popq   
%rdx                                    *
|                                                            |        retq     
                                      *
|                                                            |.LBB0_3:         
                      # %if.else      *
|                                                            |        callq  
abort                                   *
|                                                            |.Ltmp1:          
                                      *
|                                                            |        .size  
main, .Ltmp1-main                       *
|        .cfi_endproc                                        |       
.cfi_endproc                                    |
|.LFE11:                                                     |                 
                                      *
|        .size   main, .-main                                |        .type  
x1638,@object           # @x1638        *
|        .section        .text.unlikely                      |                 
                                      |
|.LCOLDE0:                                                   |                 
                                      |
|        .section        .text.startup                       |                 
                                      |
|.LHOTE0:                                                    |                 
                                      |
|        .globl  x1638                                       |                 
                                      |
|        .data                                               |        .data    
                                      |
|        .align 4                                            |        .globl 
x1638                                   *
|        .type   x1638, @object                              |        .align  4
                                      *
|        .size   x1638, 4                                    |                 
                                      |
|x1638:                                                      |x1638:           
                                      |
|        .long   1                                           |        .long   1
                      # 0x1           *
|                                                            |        .size  
x1638, 4                                *
|                                                            |                 
                                      *
+------------------------------------------------------------+--------------------------------------------------------+


clang version 3.7.0 (trunk 237801)
Target: x86_64-unknown-linux-gnu
Thread model: posix

gcc (GCC) 6.0.0 20150416 (experimental)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.</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>