[Bug c++/53364] [4.7/4.8 Regression] Wrong code generation

2012-05-16 Thread glisse at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53364

--- Comment #4 from Marc Glisse  2012-05-16 07:11:35 
UTC ---
Looking at -fdump-tree-all, 081t.phicprop1 is still the same for -O1 and -O2,
but O82t.dse1 is missing the memory writes for -O2.


[Bug c++/53364] [4.7/4.8 Regression] Wrong code generation

2012-05-15 Thread foom at fuhm dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53364

--- Comment #3 from foom at fuhm dot net 2012-05-16 04:28:21 UTC ---
> Does -fno-tree-vrp fix the issue?

Nope, "g++ -O2 -fno-tree-vrp -c test.cpp" is no different than without.


[Bug c++/53364] [4.7/4.8 Regression] Wrong code generation

2012-05-15 Thread pinskia at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53364

--- Comment #2 from Andrew Pinski  2012-05-16 
04:13:07 UTC ---
Does -fno-tree-vrp fix the issue?


[Bug c++/53364] [4.7/4.8 Regression] Wrong code generation

2012-05-15 Thread foom at fuhm dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53364

--- Comment #1 from foom at fuhm dot net 2012-05-16 04:10:59 UTC ---
Asm generated. Note that at no point is anything ever actually written to the
stack, only read from it:

 :
   0:83 3d 00 00 00 00 09 cmpl   $0x9,0x0(%rip)# 7 
   7:48 8d 44 24 e8   lea-0x18(%rsp),%rax
   c:48 8d 54 24 d8   lea-0x28(%rsp),%rdx
  11:48 0f 4f c2  cmovg  %rdx,%rax
  15:8b 00mov(%rax),%eax
  17:c3   retq   


Making what ought to be a no-op change to the program, using class "A" instead
of "B", thus:
int main() {
A a = A(10);
a = std::min(a, A(data));
return int(a);
}
causes the following, correctly working, asm to be generated. This is the same
output generated by adding "-fno-strict-aliasing" to the compile line for the
original program. See that it now does write values onto the stack locations
being read from.

(It also seems rather crazy to me that gcc doesn't optimize such a simple
program to use purely registers and no stack addresses, but I suppose that's a
different bug.)

 :
   0:8b 15 00 00 00 00mov0x0(%rip),%edx# 6 
   6:48 8d 44 24 e8   lea-0x18(%rsp),%rax
   b:48 8d 4c 24 d8   lea-0x28(%rsp),%rcx
  10:c7 44 24 d8 0a 00 00 movl   $0xa,-0x28(%rsp)
  17:00 
  18:83 fa 09 cmp$0x9,%edx
  1b:89 54 24 e8  mov%edx,-0x18(%rsp)
  1f:48 0f 4f c1  cmovg  %rcx,%rax
  23:8b 00mov(%rax),%eax
  25:c3   retq