[LLVMbugs] [Bug 22527] New: More optimize opportunity

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Feb 9 18:22:15 PST 2015


            Bug ID: 22527
           Summary: More optimize opportunity
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: ishiura-compiler at ml.kwansei.ac.jp
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

We would just like to report that GCC (4.9.2, -O3) does stronger 
optimization than Clang (3.7.0, -O3) on the following C code.
Evaluation of the arith expression (involving volatile variable a) 
is optimized out by GCC.

int main (void)
  volatile unsigned int a = 1U;

  unsigned long c = (a + 0x80000000LU) * 0xFFFFFFFFFFFFFFFELU;

  else __builtin_abort();

  return 0;

LLVM/Clang-3.7.0 "-O3 -S"

main:                                   # @main
# BB#0:                                 # %entry
  pushq    %rax
  .cfi_def_cfa_offset 16
  movl     $1, 4(%rsp)
  movl     4(%rsp), %eax
  movq     $-2147483648, %rcx           # imm = 0xFFFFFFFF80000000
  subq     %rax, %rcx
  movabsq  $9223372036854775807, %rax   # imm = 0x7FFFFFFFFFFFFFFF
  andq     %rcx, %rax
  movabsq  $9223372034707292159, %rcx   # imm = 0x7FFFFFFF7FFFFFFF
  cmpq     %rcx, %rax
  jne      .LBB0_2
# BB#1:                                 # %if.end
  xorl     %eax, %eax
  popq     %rdx
.LBB0_2:                                # %if.else
  callq    abort
  .size  main, .Ltmp1-main

  .ident  "clang version 3.7.0 (trunk 228120)"
  .section  ".note.GNU-stack","", at progbits

GCC-4.9.2 "-O3 -S"

  subq     $24, %rsp
  .cfi_def_cfa_offset 32
  movl     $1, 12(%rsp)
  movl     12(%rsp), %eax
  cmpl     $1, %eax
  jne      .L5
  xorl     %eax, %eax
  addq     $24, %rsp
  .cfi_def_cfa_offset 8
  call     abort
  .size  main, .-main
  .section  .text.unlikely
  .section  .text.startup
  .ident  "GCC: (GNU) 4.9.2"
  .section  .note.GNU-stack,"", at progbits

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150210/b33e333d/attachment.html>

More information about the llvm-bugs mailing list