[Bug c++/79005] Use of a captured variable within nested generic lambdas provokes internal compiler error.

2018-02-27 Thread lesliezhai at llvm dot org.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79005

Leslie Zhai  changed:

   What|Removed |Added

 CC||lesliezhai at llvm dot org.cn

--- Comment #7 from Leslie Zhai  ---
(In reply to Paolo Carlini from comment #6)
> Fixed in trunk.

Hi Paolo,

Could you please show me which commit fixed the issue in trunk? gcc 5/6/7
branches are still able to reproduce the issue.

Regards,
Leslie Zhai

[Bug tree-optimization/71361] [7 Regression] Changes in ivopts caused perf regression on x86

2018-02-06 Thread lesliezhai at llvm dot org.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71361

Leslie Zhai  changed:

   What|Removed |Added

 CC||lesliezhai at llvm dot org.cn

--- Comment #8 from Leslie Zhai  ---
(In reply to Jeffrey A. Law from comment #7)
> Fixed on the trunk.

Hi Jeff,

Could you please show me which commit fixed it on trunk? thanks a lot!

Regards,
Leslie Zhai

[Bug c++/71166] [7 Regression] ICE with nested constexpr/initializer

2018-02-06 Thread lesliezhai at llvm dot org.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71166

Leslie Zhai  changed:

   What|Removed |Added

 CC||lesliezhai at llvm dot org.cn

--- Comment #16 from Leslie Zhai  ---
But gcc-7-branch and 8.x trunk reverted the Remove?

-fini_constexpr ();

[Bug target/83496] MIPS BE: wrong code generates under "-Os -mbranch-cost=1"

2018-01-30 Thread lesliezhai at llvm dot org.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83496

--- Comment #15 from Leslie Zhai  ---
(In reply to Felix Fietkau from comment #10)
> (In reply to Leslie Zhai from comment #9)
> > GCC 8.0 Still reproducible:
> > 
> > 
> >  :
> >0:   8c830008lw  v1,8(a0)
> >4:   24020001li  v0,1
> >8:   1062000dbeq v1,v0,40 
> >c:   nop
> >   10:   8c83lw  v1,0(a0)
> >   14:   28630002sltiv1,v1,2
> >   18:   106bbeqzv1,48 
> >   1c:   nop
> >   20:   dc820010ld  v0,16(a0)
> >   24:   dc42ld  v0,0(v0)
> >   28:   00a2182bsltuv1,a1,v0
> >   2c:   1466bnezv1,48 
> >   30:   nop
> >   34:   0045102bsltuv0,v0,a1
> >   38:   03e8jr  ra
> >   3c:   0002102fdnegu   v0,v0
> >   40:   03e8jr  ra
> >   44:   2402li  v0,-1
> >   48:   03e8jr  ra
> >   4c:   24020001li  v0,1
> 
> Actually, I think that assembly looks unaffected by the issue.
> 


Thanks for your response! I am also tracking the issue
https://github.com/loongson-community/gcc/issues/4

I will compare with LLVM 7.x's Mips Target :)

[Bug tree-optimization/65968] Failure to remove casts, cause poor code generation

2018-01-29 Thread lesliezhai at llvm dot org.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65968

Leslie Zhai  changed:

   What|Removed |Added

 CC||lesliezhai at llvm dot org.cn

--- Comment #2 from Leslie Zhai  ---
not generated poor code for Mips target:


.file   1 "t.c"
.section .mdebug.abi64
.previous
.nanlegacy
.module fp=64
.module oddspreg
.abicalls
.text
.align  2
.align  3
.globl  f
.setnomips16
.setnomicromips
.entf
.type   f, @function
f:
.frame  $sp,0,$31   # vars= 0, regs= 0/0, args= 0, gp= 0
.mask   0x,0
.fmask  0x,0
.setnoreorder
.setnomacro
li  $3,8388608  # 0x80
daddu   $3,$4,$3
.align  3
.L2:
lh  $2,0($4)
daddiu  $4,$4,2
mul $2,$2,$2
bne $3,$4,.L2
sh  $2,-2($4)

j   $31
nop

.setmacro
.setreorder
.endf
.size   f, .-f
.ident  "GCC: (GNU) 5.5.0 20171010 (LLVM China GCC 5.5-2018.01)"

[Bug tree-optimization/83190] missing strlen optimization of the empty string

2018-01-22 Thread lesliezhai at llvm dot org.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83190

Leslie Zhai  changed:

   What|Removed |Added

 CC||lesliezhai at llvm dot org.cn

--- Comment #6 from Leslie Zhai  ---
(In reply to Martin Sebor from comment #1)
> Clang emits optimal code for both functions.

Yep!

; ModuleID = 'a.c'
source_filename = "a.c"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-redhat-linux"

; Function Attrs: norecurse nounwind readnone uwtable
define i32 @f() local_unnamed_addr #0 {
  ret i32 0
}

; Function Attrs: norecurse nounwind readnone uwtable
define i32 @g() local_unnamed_addr #0 {
  ret i32 0
}

attributes #0 = { norecurse nounwind readnone uwtable
"correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false"
"less-precise-fpmad"="false" "no-frame-pointer-elim"="false"
"no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false"
"no-signed-zeros-fp-math"="false" "no-trapping-math"="false"
"stack-protector-buffer-size"="8" "target-cpu"="x86-64"
"target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false"
"use-soft-float"="false" }

!llvm.module.flags = !{!0}
!llvm.ident = !{!1}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{!"LLVM China clang version 7.0.0 (g...@github.com:llvm-mirror/clang.git
87bcdaa7f2311f57c35c18efc6cbf5a973a67de7) (g...@github.com:llvm-mirror/llvm.git
4eeea16aaacd6134fd411abcdbab15b630f3302b) (based on LLVM 7.0.0svn)"}

[Bug middle-end/71304] missing strlen optimizations after string truncation by assigning NUL

2018-01-22 Thread lesliezhai at llvm dot org.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71304

Leslie Zhai  changed:

   What|Removed |Added

 CC||lesliezhai at llvm dot org.cn

--- Comment #4 from Leslie Zhai  ---
(In reply to Martin Sebor from comment #3)
> Not working on the patch anymore.

GCC 8.x works:
$ /opt/mips-gnu-git/bin/mips64-linux-gnu-gcc -O2 -S -Wall -Wextra
-fdump-tree-optimized=/dev/stdout -o/dev/stdout t.c   
.file   1 "t.c"
.section .mdebug.abi64
.previous
.nanlegacy
.module fp=64
.module oddspreg
.abicalls
.text

;; Function f (f, funcdef_no=0, decl_uid=1582, cgraph_uid=0, symbol_order=0)

f ()
{
   [local count: 1073741825]:
  return 1;

}


.align  2
.align  3
.globl  f
.setnomips16
.setnomicromips
.entf
.type   f, @function
f:
.frame  $sp,0,$31   # vars= 0, regs= 0/0, args= 0, gp= 0
.mask   0x,0
.fmask  0x,0
.setnoreorder
.setnomacro
jr  $31
li  $2,1# 0x1

.setmacro
.setreorder
.endf
.size   f, .-f

;; Function g (g, funcdef_no=1, decl_uid=1586, cgraph_uid=1, symbol_order=1)

g ()
{
   [local count: 1073741825]:
  return 1;

}


.align  2
.align  3
.globl  g
.setnomips16
.setnomicromips
.entg
.type   g, @function
g:
.frame  $sp,0,$31   # vars= 0, regs= 0/0, args= 0, gp= 0
.mask   0x,0
.fmask  0x,0
.setnoreorder
.setnomacro
jr  $31
li  $2,1# 0x1

.setmacro
.setreorder
.endg
.size   g, .-g
.ident  "GCC: (GNU) 8.0.1 20180123 (experimental)"


Could you tell me which commit fix the issue please? thanks a lot!

Regards,
Leslie Zhai

[Bug tree-optimization/83821] local aggregate initialization defeats strlen optimization

2018-01-22 Thread lesliezhai at llvm dot org.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83821

Leslie Zhai  changed:

   What|Removed |Added

 CC||lesliezhai at llvm dot org.cn

--- Comment #3 from Leslie Zhai  ---
(In reply to Martin Sebor from comment #0)
> For the test case below, GCC optimizes the strlen call in f() but fails to
> do the same in g().  It appears because the maybe_invalidate() function in
> the pass considers the initialization of/assignment to b.i as possibly
> clobbering the value of b.s, not realizing that there is no way for the two
> members to alias.
> 
> $ cat z.c && gcc -O2 -S -fdump-tree-optimized=/dev/stdout z.c 
> #define STR "0123456789"
> 
> struct A
> {
>   char s[sizeof STR];
> };
> 
> void f (void)
> {
>   struct A a = { STR };
>   if (__builtin_strlen (a.s) != sizeof STR - 1)   // folded
> __builtin_abort ();   // eliminated
> }
> 
> struct B
> {
>   char s[sizeof STR];
>   int i;
> };
> 
> void g (void)
> {
>   struct B b = { STR, 123 };
>   if (__builtin_strlen (b.s) != sizeof STR - 1)   // not folded
> __builtin_abort ();   // not eliminated
> }
> 
> 
> ;; Function f (f, funcdef_no=0, decl_uid=1952, cgraph_uid=0, symbol_order=0)
> 
> f ()
> {
>[local count: 1073741825]:
>   return;
> 
> }
> 
> 
> 
> ;; Function g (g, funcdef_no=1, decl_uid=1959, cgraph_uid=1, symbol_order=1)
> 
> g ()
> {
>   struct B b;
>   long unsigned int _1;
> 
>[local count: 1073741825]:
>   b.s = "0123456789";
>   b.i = 123;
>   _1 = __builtin_strlen ();
>   if (_1 != 10)
> goto ; [0.00%]
>   else
> goto ; [99.96%]
> 
>[count: 0]:
>   __builtin_abort ();
> 
>[local count: 1073312327]:
>   b ={v} {CLOBBER};
>   return;
> 
> }


$ /opt/mips-gnu-git/bin/mips64-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=/opt/mips-gnu-git/bin/mips64-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/opt/mips-gnu-git/libexec/gcc/mips64-linux-gnu/8.0.1/lto-wrapper
Target: mips64-linux-gnu
Configured with: ../configure --prefix=/opt/mips-gnu-git
--build=x86_64-redhat-linux-gnu --disable-decimal-float
--disable-dependency-tracking --disable-gold --disable-libgcj --disable-libgomp
--disable-libmpx --disable-libquadmath --disable-libssp
--disable-libunwind-exceptions --disable-shared --disable-silent-rules
--disable-sjlj-exceptions --disable-threads
--with-ld=/usr/bin/mips64-linux-gnu-ld --enable-__cxa_atexit
--enable-checking=release --enable-gnu-unique-object --enable-initfini-array
--enable-languages=c,c++ --enable-linker-build-id --enable-lto --enable-nls
--enable-obsolete --enable-plugin --enable-targets=all
--host=x86_64-redhat-linux-gnu --target=mips64-linux-gnu --with-newlib
--with-plugin-ld=/usr/bin/mips64-linux-gnu-ld --with-system-libunwind
--with-system-zlib --without-headers --with-arch=mips64r2 --with-abi=64
--with-arch_32=mips32r2 --with-fp-32=xx --enable-gnu-indirect-function
Thread model: single
gcc version 8.0.1 20180123 (experimental) (GCC)


But GCC also failed to optimize the strlen call in f() after applied your patch
$ /opt/mips-gnu-git/bin/mips64-linux-gnu-gcc -O2 -S
-fdump-tree-optimized=/dev/stdout z.c   

;; Function f (f, funcdef_no=0, decl_uid=1584, cgraph_uid=0, symbol_order=0)

f ()
{
  struct A a;
  long unsigned int _1;

   [local count: 1073741825]:
  a = *.LC0;
  _1 = __builtin_strlen ();
  if (_1 != 10)
goto ; [0.00%]
  else
goto ; [99.96%]

   [count: 0]:
  __builtin_abort ();

   [local count: 1073312327]:
  a ={v} {CLOBBER};
  return;

}



;; Function g (g, funcdef_no=1, decl_uid=1591, cgraph_uid=1, symbol_order=1)

g ()
{
  struct B b;
  long unsigned int _1;

   [local count: 1073741825]:
  b = *.LC1;
  _1 = __builtin_strlen ();
  if (_1 != 10)
goto ; [0.00%]
  else
goto ; [99.96%]

   [count: 0]:
  __builtin_abort ();

   [local count: 1073312327]:
  b ={v} {CLOBBER};
  return;

}

[Bug target/83496] MIPS BE: wrong code generates under "-Os -mbranch-cost=1"

2018-01-21 Thread lesliezhai at llvm dot org.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83496

Leslie Zhai  changed:

   What|Removed |Added

 CC||lesliezhai at llvm dot org.cn

--- Comment #9 from Leslie Zhai  ---
(In reply to Paul Hua from comment #8)
> On GCC 8.x, the r248351 fixed this.
> 
> commit fd891ec7f659e8785c3ed5757f6e60c95117b837
> Author: segher <segher@138bc75d-0d04-0410-961f-82ee72b054a4>
> Date:   Mon May 22 21:20:51 2017 +
> 
> cfgcleanup: Ignore clobbers in bb_is_just_return
> 
> The function bb_is_just_return finds if the BB it is asked about does
> just a return and nothing else.  It currently does not allow clobbers
> in the block either, which we of course can allow just fine.
> 
> This patch changes that.
> 
> 
> * cfgcleanup.c (bb_is_just_return): Allow CLOBBERs.
> 
> gcc/testsuite/
> 
> 
> 
> git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@248351
> 138bc75d-0d04-0410-961f-82ee72b054a4
> 
> 
> Paul Hua


GCC 8.0 Still reproducible:


 :
   0:   8c830008lw  v1,8(a0)
   4:   24020001li  v0,1
   8:   1062000dbeq v1,v0,40 <mytest+0x40>
   c:   nop
  10:   8c83lw  v1,0(a0)
  14:   28630002sltiv1,v1,2
  18:   106bbeqzv1,48 <mytest+0x48>
  1c:   nop
  20:   dc820010ld  v0,16(a0)
  24:   dc42ld  v0,0(v0)
  28:   00a2182bsltuv1,a1,v0
  2c:   1466bnezv1,48 <mytest+0x48>
  30:   nop
  34:   0045102bsltuv0,v0,a1
  38:   03e8jr  ra
  3c:   0002102fdnegu   v0,v0
  40:   03e8jr  ra
  44:   2402li  v0,-1
  48:   03e8jr  ra
  4c:   24020001li  v0,1



$ /opt/mips-gnu-git/bin/mips64-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=/opt/mips-gnu-git/bin/mips64-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/opt/mips-gnu-git/libexec/gcc/mips64-linux-gnu/8.0.1/lto-wrapper
Target: mips64-linux-gnu
Configured with: ../configure --target=mips64-linux-gnu
--host=x86_64-redhat-linux-gnu --build=x86_64-redhat-linux-gnu
--prefix=/opt/mips-gnu-git --disable-decimal-float
--disable-dependency-tracking --disable-gold --disable-libgcj --disable-libgomp
--disable-libmpx --disable-libquadmath --disable-libssp
--disable-libunwind-exceptions --disable-shared --disable-silent-rules
--disable-sjlj-exceptions --disable-threads --enable-__cxa_atexit
--enable-checking=release --enable-gnu-unique-object --enable-initfini-array
--enable-languages=c,c++ --enable-linker-build-id --enable-lto --enable-nls
--enable-obsolete --enable-plugin --enable-targets=all --with-newlib
--with-system-libunwind --with-system-zlib --with-arch=mips64r2 --with-abi=64
--with-arch_32=mips32r2 --with-fp-32=xx --enable-gnu-indirect-function
Thread model: single
gcc version 8.0.1 20180120 (experimental) (GCC)


Regards,
Leslie Zhai

[Bug middle-end/83764] internal compiler error: in gimple_get_virt_method_for_vtable

2018-01-09 Thread lesliezhai at llvm dot org.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83764

--- Comment #2 from Leslie Zhai  ---
And GCC 8.x workaround just remove the assert:

6751   /* The virtual tables should always be born with constructors
6752  and we always should assume that they are avaialble for   
6753  folding.  At the moment we do not stream them in all cases,   
6754  but it should never happen that ctor seem unreachable.  */
6755   gcc_assert (init);   
6756   if (init == error_mark_node) 
6757 {  
6758   /* Pass down that we lost track of the target.  */   
6759   if (can_refer)   
6760 *can_refer = false;
6761   return NULL_TREE;
6762 }

[Bug middle-end/83764] internal compiler error: in gimple_get_virt_method_for_vtable

2018-01-09 Thread lesliezhai at llvm dot org.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83764

--- Comment #1 from Leslie Zhai  ---
Typo:
- I have no idea why `in_lto_p` is NULL?
+ I have no idea why `in_lto_p` is false?

[Bug middle-end/83764] New: internal compiler error: in gimple_get_virt_method_for_vtable

2018-01-09 Thread lesliezhai at llvm dot org.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83764

Bug ID: 83764
   Summary: internal compiler error: in
gimple_get_virt_method_for_vtable
   Product: gcc
   Version: 7.2.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: middle-end
  Assignee: unassigned at gcc dot gnu.org
  Reporter: lesliezhai at llvm dot org.cn
  Target Milestone: ---

Hi GCC developers,

When I use Linaro GCC 7.2-2017.11 arm-linux-gnueabihf cross-compile
toolchain[1] to build L4Re and L4Linux[2] 

Toolchain thrown such error:
/data/project/xiangzhai/l4re/l4/pkg/io/io/server/src/virt/vmsi.cc:28:1:
internal compiler error: in gimple_get_virt_method_for_vtable, at
gimple-fold.c:6467
 }
 ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.


l4re/l4/pkg/io/io/server/src/virt/vmsi.cc:28 define a static variable in an
anonymous namespace[3]

26 namespace {  
27   static Vi::Resource_factory_t<Vi::Msi_resource, Hw::Msi_resource>
__vmsifactory;
28 }


Linaro gcc-7.2.1/gcc/gimple-fold.c:6467 call gcc_assert[4]

6460   /* The virtual tables should always be born with constructors
6461  and we always should assume that they are avaialble for   
6462  folding.  At the moment we do not stream them in all cases,   
6463  but it should never happen that ctor seem unreachable.  */
6464   gcc_assert (init);   
6465   if (init == error_mark_node) 
6466 {  
6467   gcc_assert (in_lto_p);   
6468   /* Pass down that we lost track of the target.  */   
6469   if (can_refer)   
6470 *can_refer = false;
6471   return NULL_TREE;
6472 }

I have no idea why `in_lto_p` is NULL?
Please give me some suggestion, thanks a lot!

[1]
https://releases.linaro.org/components/toolchain/binaries/latest/arm-linux-gnueabihf/gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabihf.tar.xz
[2] http://os.inf.tu-dresden.de/pipermail/l4-hackers/2018/008189.html
[3]
https://svn.l4re.org/repos/oc/l4re/trunk/l4/pkg/io/io/server/src/virt/vmsi.cc
[4]
https://releases.linaro.org/components/toolchain/gcc-linaro/latest/gcc-linaro-7.2-2017.11.tar.xz

Regards,
Leslie Zhai