[Bug rtl-optimization/38544] New: missed opportunity to use adc

2008-12-16 Thread rrh at google dot com
The optimizer at -O3 for x86_64 finds opportunities to generate the adc (add
with carry) instruction to avoid a conditional branch.  However, the dst of the
adc can only be in a register.  The optimizer misses a chance to use adc with
the destination in memory, and will instead use a conditional branch in a
straightforward manner.  The following program shows that foo1 uses adc, but
foo0 does not.

Although I haven't tested this, I'm sure that the other 3 possibilities in this
family (involving sbb and/or different literal values to add/subtract) will
also not find the opportunity to do a memory update with adc.

extern void consumep(int *);
extern void consume(int);
void foo0(unsigned a, unsigned b, int *victim)
{
  if (a  b) { (*victim)++; }
  consumep(victim);
}
void foo1(unsigned a, unsigned b, int victim)
{
  if (a  b) { victim++; }
  consume(victim);
}


-- 
   Summary: missed opportunity to use adc
   Product: gcc
   Version: 4.4.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: rtl-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: rrh at google dot com
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


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



[Bug translation/38120] New: missing space in x86 assembly code for some mov instructions

2008-11-14 Thread rrh at google dot com
the x86_64 assembly code generator will emit stuff like:
  movswl  406(%rbx),%eax
To be consistent with all the other assembly language output, the output should
have a space after the , eg:
  movswl  406(%rbx), %eax
Doing a
  grep ',%' ./config/i386/i386.md
shows 40 lines that might need to be touched up.


-- 
   Summary: missing space in x86 assembly code for some mov
instructions
   Product: gcc
   Version: 4.4.0
Status: UNCONFIRMED
  Severity: trivial
  Priority: P3
 Component: translation
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: rrh at google dot com
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


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



[Bug c/37783] New: double (a+a)-(b+b) fetches constant 2.0, rather than using subtract

2008-10-09 Thread rrh at google dot com
the following code
double aaminusbb (const double a, const double b) { return (a+a)-(b+b); }
yields:
addsd   %xmm0, %xmm0
mulsd   .LC0(%rip), %xmm1
addsd   %xmm1, %xmm0
ret
Where LC0 holds -2.0.

There's a perfectly good subtract instruction.  Using it will avoid the memory
load to fetch the constant -2.0.  Perhaps something like:
addsd   %xmm0, %xmm0
addsd   %xmm1, %xmm1
subsd   %xmm1, %xmm0
ret


-- 
   Summary: double (a+a)-(b+b) fetches constant 2.0, rather than
using subtract
   Product: gcc
   Version: 4.4.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: rrh at google dot com
 GCC build triplet: i686-host_pc-linux-gnu
  GCC host triplet: i686-host_pc-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


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



[Bug c/37783] double (a+a)-(b+b) fetches constant 2.0, rather than using subtract

2008-10-09 Thread rrh at google dot com


--- Comment #1 from rrh at google dot com  2008-10-09 16:38 ---
I should have added that this is for -O, -O2, -O3.


-- 


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



[Bug rtl-optimization/37784] New: inefficient code for double compare double yielding double

2008-10-09 Thread rrh at google dot com
The function:
double dfunc_001 ( const double a, const double b) { return a  b; }
yields the x86_64 code:
cmpltsd %xmm0, %xmm1
movapd  %xmm1, %xmm0
movsd   .LC1(%rip), %xmm1
andpd   %xmm0, %xmm1
xorpd   %xmm2, %xmm2
andnpd  %xmm2, %xmm0
orpd%xmm1, %xmm0
ret
.LC1:
.long   0
.long   1072693248
Where LC1 is the fp constant +1.0

The 3 instruction sequence preceding the ret (eg xorpd;andnpd;orpd) is not
needed.  The xorpd generates a 0, which is anded with something to yield a 0,
which is or'ed in with the value (+0.0 or +1.0) to yield the result.

Similar illness is seen for the other compares built around cmpsd variants.

Some improvement is seen when compiling -O3, but in that case there are 2
unneeded instructions.


-- 
   Summary: inefficient code for double compare double yielding
double
   Product: gcc
   Version: 4.4.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: rtl-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: rrh at google dot com
 GCC build triplet: i686-host_pc-linux-gnu
  GCC host triplet: i686-host_pc-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


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