[Bug tree-optimization/66299] New: more optimize oppotunity
ishiura-compiler at ml dot kwansei.ac.jp
gcc-bugzilla@gcc.gnu.org
Wed May 27 07:34:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66299
Bug ID: 66299
Summary: more optimize oppotunity
Product: gcc
Version: 6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: ishiura-compiler at ml dot kwansei.ac.jp
Target Milestone: ---
We compiled a program (A.c) by GCC-6.0.0 and LLVM/Clang-3.7.0 with -O3 option.
LLVM/Clang worked better on this test case, where the shift operation is
optimized out.
(A.c)
int main (void)
{
volatile signed int x = 1;
unsigned int t = ((unsigned int)1U<<x);
if (t == 2U) ;
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 |
| subq $24, %rsp |# BB#0:
# %entry *
| .cfi_def_cfa_offset 32 | pushq %rax
*
| movl $1, %eax |.Ltmp0:
*
| movl $1, 12(%rsp) |
.cfi_def_cfa_offset 16 *
| movl 12(%rsp), %ecx | movl $1,
4(%rsp) *
| sall %cl, %eax | movl
4(%rsp), %eax *
| cmpl $2, %eax | cmpl $1,
%eax *
| jne .L5 | jne
.LBB0_2 *
| |# BB#1:
# %if.end *
| xorl %eax, %eax | xorl %eax,
%eax |
| addq $24, %rsp | popq %rdx
*
| .cfi_remember_state | retq
*
| .cfi_def_cfa_offset 8 |.LBB0_2:
# %if.else *
| ret | callq abort
*
|.L5: |.Ltmp1:
*
| .cfi_restore_state | .size main,
.Ltmp1-main *
| call abort |
|
| .cfi_endproc | .cfi_endproc
|
|.LFE11: |
*
| .size\tmain, .-main |
*
| .section .text.unlikely |
*
|.LCOLDE0: |
*
| .section .text.startup |
|
|.LHOTE0: |
|
+--------------------------------------------------------+------------------------------------------------------+
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.
clang version 3.7.0 (trunk 237801)
Target: x86_64-unknown-linux-gnu
Thread model: posix
More information about the Gcc-bugs
mailing list