This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/47579] STL size() == 0 does unnecessary shift


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47579

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-01-06
     Ever Confirmed|0                           |1

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-01-06 00:32:36 UTC ---
Two more interesting testcases:
void f(int *a, int *b)  {if((b-a)==0) b1(); else b2();}
void f1(int *a, int *b)
{
  std::size_t t = a-b;
  if (t == 0)  b1(); else b2();
}
--- CUT ---
f produces:
    .cfi_startproc
    subq    %rdi, %rsi
    addq    $3, %rsi
    cmpq    $6, %rsi
    jbe    .L7
    jmp    _Z2b2v
    .p2align 4,,10
    .p2align 3
.L7:
    jmp    _Z2b1v
    .cfi_endproc

While f1 produces:
    .cfi_startproc
    subq    %rsi, %rdi
    sarq    $2, %rdi
    testq    %rdi, %rdi
    je    .L10
    jmp    _Z2b2v
    .p2align 4,,10
    .p2align 3
.L10:
    jmp    _Z2b1v
    .cfi_endproc
Which is the same as your foo.  So we should be able to do the same as f for
foo.
f:
  b.2_2 = (long int) b_1(D);
  a.3_4 = (long int) a_3(D);
  D.8126_5 = b.2_2 - a.3_4;
  D.8127_6 = (long unsigned int) D.8126_5;
  D.8128_7 = D.8127_6 + 3;
  if (D.8128_7 <= 6)
    goto <bb 3>;
  else
    goto <bb 4>;

f1 (and foo really):
  a.0_2 = (long int) a_1(D);
  b.1_4 = (long int) b_3(D);
  D.8119_5 = a.0_2 - b.1_4;
  D.8120_6 = D.8119_5 /[ex] 4;
  if (D.8120_6 == 0)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]