[Bug rtl-optimization/31271] New: Missing simple optimization

2007-03-19 Thread matt at 3am-software dot com
The following shows a missing easy optimization for GCC:

int
in_canforward(unsigned int in)
{
if ((in & ~0xff0f) == 0xf0 || (in & ~0xff0f) == 0xe0)
return 0;
return 1;
}

results in (@ -O2):

in_canforward:
andl$240, %edi
cmpl$240, %edi
sete%al
cmpl$224, %edi
sete%dl
orl %edx, %eax
xorl$1, %eax
movzbl  %al, %eax
ret

given that 0xf0 and 0xe0 only differ by one bit, there is no reason to test for
that bit so the comparision could be: (in & 0xff1f) == 0xe0.  More
generally
the optimization is:

given   (x & m) == a0 || (x & m) == a1
where m, a0, and a1 are all constant
let b = (a0 ^ a1)
then if (b & (b - 1)) == 0 [b is a power of 2]
rewrite to: (x & (m|b)) == (a0 & ~b)


-- 
   Summary: Missing simple optimization
   Product: gcc
   Version: 4.3.0
Status: UNCONFIRMED
  Severity: enhancement
  Priority: P3
 Component: rtl-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: matt at 3am-software dot com
 GCC build triplet: x86_64--netbsd
  GCC host triplet: x86_64--netbsd
GCC target triplet: x86_64--netbsd


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



[Bug tree-optimization/31272] New: gcc is being too clever

2007-03-19 Thread matt at 3am-software dot com
[This problem occurs in 4.1.2 and 4.1.3 as well]
Given the following source:

int
in_canforward(unsigned int in)
{
unsigned int net;

if ((in & ~0xff0f) == 0xf0 || (in & ~0xff0f) == 0xe0)
return 0;
if ((in & 0x80) == 0) {
net = in & 0xff;
if (net == 0 || net == 0x7f)
return 0;
}
return 1;

"cc1 -O2 -quiet" emit:  

#NO_APP
.file   "inc.c"
.text
.align 1
.globl in_canforward
.type   in_canforward, @function
in_canforward:
.word 0x0
subl2 $4,%sp
movl 4(%ap),%r1
bicl3 $-241,%r1,%r0
cmpl %r0,$240
jeql .L2
cmpl %r0,$224
jeql .L2
bicb3 $127,%r1,%r0
jneq .L12
bicl2 $-256,%r1
jneq .L13
.L2:
clrl %r0
ret
.L12:
movl $1,%r0
ret
.L13:
cmpl %r1,$127
jeql .L14
xorb2 $1,%r0
movzbl %r0,%r0
ret
.L14:
movb $1,%r0
xorb2 $1,%r0
movzbl %r0,%r0
ret
.size   in_canforward, .-in_canforward
.ident  "GCC: (GNU) 4.3.0 20070319 (experimental)"

Notice the code at .L14?  Why go through all extra that effort?  Why not just
do clrl %r0 and ret or preferrably branch to .L2 which already does that?  The
same argument goes for the xorb2/movzbl right  before .L14.   movl $1,%r0 and
ret or preferably branch to .L12 which already does that.

Now if you move .L13 before .L12 (so it can all fall through) and take the
mentioned branches, the almost-optimal version becomes:

in_canforward:
.word 0x0
subl2 $4,%sp
movl 4(%ap),%r1
bicl3 $-241,%r1,%r0
cmpl %r0,$240
jeql .L2
cmpl %r0,$224
jeql .L2
bicb3 $127,%r1,%r0
jneq .L12
bicl2 $-256,%r1
jneq .L13
.L2:
clrl %r0
ret
.L13:
cmpl %r1,$127
jeql .L2
.L12:
movl $1,%r0
ret


-- 
   Summary: gcc is being too clever
   Product: gcc
   Version: 4.3.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
    ReportedBy: matt at 3am-software dot com
 GCC build triplet: x86_64--netbsd
  GCC host triplet: x86_64--netbsd
GCC target triplet: vax--netbsdelf


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



[Bug pending/31709] New: combine and __attributes__((__packed__)) conflict.

2007-04-25 Thread matt at 3am-software dot com
a.c:

struct f { int i; } __attribute__((__packed__));

const char *foo(struct f *);

b.c:

struct f;

const char *foo(struct f *);

c.c (identical to a.c):

struct f { int i; } __attribute__((__packed__));

const char *foo(struct f *);


gcc -fsyntax-only -combine -ffreestanding a.c b.c c.c 
c.c:3: error: conflicting types for 'foo'
b.c:3: error: previous declaration of 'foo' was here

There is no difference even if b.c includes attribute((__packed__)).  Changing
the order such that b.c is either first or last suppresses the error.


-- 
   Summary: combine and __attributes__((__packed__)) conflict.
   Product: gcc
   Version: 4.1.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: pending
AssignedTo: unassigned at gcc dot gnu dot org
    ReportedBy: matt at 3am-software dot com
 GCC build triplet: x86_64--netbsd
  GCC host triplet: x86_64--netbsd
GCC target triplet: x86_64--netbsd


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



[Bug testsuite/37628] New: gcc.c-torture/execute/pr35456.c is not generic

2008-09-23 Thread matt at 3am-software dot com
It assumes the existence of signed 0.0 which is not available across all FP
implementations.  Specifically, this test fails on VAX since VAX FP has no
concept of -0.0.  In fact, -0.0 would cause a reserved operand fault.


-- 
   Summary: gcc.c-torture/execute/pr35456.c is not generic
   Product: gcc
   Version: 4.4.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: testsuite
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: matt at 3am-software dot com
 GCC build triplet: x86-64--netbsd
  GCC host triplet: x86_64--netbsd
GCC target triplet: vax--netbsdelf


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



[Bug testsuite/37630] New: gcc.dg/20001012-1.c depends on IEEE FP encoding

2008-09-23 Thread matt at 3am-software dot com
and thus fails on platforms which don't use IEEE FP encoding such as VAX.


-- 
   Summary: gcc.dg/20001012-1.c depends on IEEE FP encoding
   Product: gcc
   Version: 4.4.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: testsuite
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: matt at 3am-software dot com
 GCC build triplet: x86-64--netbsd
  GCC host triplet: x86_64--netbsd
GCC target triplet: vax--netbsdelf


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



[Bug regression/21198] New: Packed bitfield structure copies are very inefficient

2005-04-24 Thread matt at 3am-software dot com
In a digression from 2.95, gcc 4.1 copies a packed bitfield structure member by 
member instead of 
doing as an aggregate.

Given the program:

struct __attribute__((packed)) A { unsigned short i : 1, l : 1, j : 3, k : 11; 
};
struct A sA;
struct A retmeA (struct A x) { return x; }

GCC 4.1 -O3 compiles that as:

.align 1
.globl retmeA
.type   retmeA, @function
retmeA:
.word 0x0
subl2 $4,%sp
movl %r1,%r0
movw 4(%ap),%r2
rotl $30,%r2,%r3
bicl2 $-8,%r3
rotl $31,%r2,%r4
bicl2 $-2,%r4
rotl $27,%r2,%r1
bicl2 $-2048,%r1
insv %r1,$5,$11,(%r0)
insv %r3,$2,$3,(%r0)
insv %r4,$1,$1,(%r0)
insv %r2,$0,$1,(%r0)
ret
.size   retmeA, .-retmeA

Whereas GCC 2.95.3 compiled it to:

.globl retmeA
.typeretmeA,@function
retmeA:
.word 0x0
movw 4(%ap),(%r1)
ret

-- 
   Summary: Packed bitfield structure copies are very inefficient
   Product: gcc
   Version: 4.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: regression
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: matt at 3am-software dot com
CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: x86_64--netbsd
  GCC host triplet: x86_64--netbsd
GCC target triplet: vax--netbsdelf


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


[Bug rtl-optimization/21307] New: internal compiler error: in change_address_1, at emit-rtl.c:1768

2005-04-30 Thread matt at 3am-software dot com
Using built-in specs.
Target: vax--netbsdelf
Configured with: /u1/toolchain/gcc/configure --target=vax--netbsdelf
--build=x86_64--netbsd --host=x86_64--netbsd --disable-shared --disable-threads
--prefix=/usr/gcc
Thread model: single
gcc version 4.1.0 20050422 (experimental)
 /usr/gcc/libexec/gcc/vax--netbsdelf/4.1.0/cc1 -E -quiet -nostdinc -v
-I/usr/src/lib/libc/citrus -DLOCALEMOD_MAJOR=4 -DLIBC_SCCS -isystem
/u1/vax/root/usr/include /usr/src/lib/libc/citrus/modules/citrus_utf7.c -O2
-fpch-preprocess -o citrus_utf7.i
#include "..." search starts here:
#include <...> search starts here:
 /usr/src/lib/libc/citrus
 /u1/vax/root/usr/include
End of search list.
# cc1 0.02 0.00
 /usr/gcc/libexec/gcc/vax--netbsdelf/4.1.0/cc1 -fpreprocessed citrus_utf7.i
-quiet -dumpbase citrus_utf7.c -auxbase-strip citrus_utf7.o.tmp -O2 -version -o
citrus_utf7.s
GNU C version 4.1.0 20050422 (experimental) (vax--netbsdelf)
compiled by GNU C version 3.3.3 (NetBSD nb3 20040520).
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
/usr/src/lib/libc/citrus/modules/citrus_utf7.c: In function '_mbtoutf16':
/usr/src/lib/libc/citrus/modules/citrus_utf7.c:279: internal compiler error: in
change_address_1, at emit-rtl.c:1768
Please submit a full bug report,
with preprocessed source if appropriate.
See http://gcc.gnu.org/bugs.html> for instructions.
# cc1 0.07 0.01

-- 
   Summary: internal compiler error: in change_address_1, at emit-
rtl.c:1768
   Product: gcc
   Version: 4.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: rtl-optimization
AssignedTo: unassigned at gcc dot gnu dot org
    ReportedBy: matt at 3am-software dot com
CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: x86_64-netbsd
  GCC host triplet: x86_64--netbsd
GCC target triplet: vax--netbsdelf


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


[Bug rtl-optimization/21307] internal compiler error: in change_address_1, at emit-rtl.c:1768

2005-04-30 Thread matt at 3am-software dot com

--- Additional Comments From matt at 3am-software dot com  2005-04-30 21:29 
---
Created an attachment (id=8774)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=8774&action=view)
C file causing the ICE


-- 


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


[Bug target/21309] New: internal compiler error: in expand_mult_const, at expmed.c:2884

2005-04-30 Thread matt at 3am-software dot com
 expand_expr (exp=0x2010aee10, target=0x200eed400, 
mode=VOIDmode, modifier=EXPAND_NORMAL) at expr.h:487
#19 0x0079e715 in expand_expr_stmt (exp=0x2010aee10)
at /u1/toolchain/gcc/gcc/stmt.c:1340
#20 0x007fe8a2 in expand_gimple_basic_block (bb=0x20118b270, 
dump_file=0x0) at /u1/toolchain/gcc/gcc/cfgexpand.c:1131
#21 0x007fefea in tree_expand_cfg ()
at /u1/toolchain/gcc/gcc/cfgexpand.c:1304
#22 0x004c7e88 in execute_one_pass (pass=0xa8a6a0)
at /u1/toolchain/gcc/gcc/tree-optimize.c:578
#23 0x004c7f6f in execute_pass_list (pass=0xa8a6a0)
at /u1/toolchain/gcc/gcc/tree-optimize.c:615
#24 0x004c828f in tree_rest_of_compilation (fndecl=0x2010b0dd0)
at /u1/toolchain/gcc/gcc/tree-optimize.c:728
#25 0x0041ed93 in c_expand_body (fndecl=0x2010b0dd0)
at /u1/toolchain/gcc/gcc/c-decl.c:6411
#26 0x0081e932 in cgraph_expand_function (node=0x201179a90)
at /u1/toolchain/gcc/gcc/cgraphunit.c:924
#27 0x0081ebc4 in cgraph_expand_all_functions ()
---Type  to continue, or q  to quit---
at /u1/toolchain/gcc/gcc/cgraphunit.c:988
#28 0x0081ef17 in cgraph_optimize ()
at /u1/toolchain/gcc/gcc/cgraphunit.c:1090
#29 0x004219d2 in c_write_global_declarations ()
at /u1/toolchain/gcc/gcc/c-decl.c:7395
#30 0x007b20d5 in compile_file ()
at /u1/toolchain/gcc/gcc/toplev.c:1013
#31 0x007b38bd in do_compile () at /u1/toolchain/gcc/gcc/toplev.c:2123
#32 0x007b3924 in toplev_main (argc=19, argv=0x7f7feaa8)
at /u1/toolchain/gcc/gcc/toplev.c:2155
#33 0x00499057 in main (argc=19, argv=0x7f7feaa8)
at /u1/toolchain/gcc/gcc/main.c:35

-- 
   Summary: internal compiler error: in expand_mult_const, at
expmed.c:2884
   Product: gcc
   Version: 4.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: matt at 3am-software dot com
CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: x86_64--netbsd
  GCC host triplet: x86_64--netbsd
GCC target triplet: vax--netbsdelf


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


[Bug target/21309] internal compiler error: in expand_mult_const, at expmed.c:2884

2005-04-30 Thread matt at 3am-software dot com

--- Additional Comments From matt at 3am-software dot com  2005-04-30 22:04 
---
Created an attachment (id=8776)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=8776&action=view)
source file exhibiting problem


-- 


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


[Bug target/21309] internal compiler error: in expand_mult_const, at expmed.c:2884

2005-04-30 Thread matt at 3am-software dot com

--- Additional Comments From matt at 3am-software dot com  2005-04-30 22:11 
---
Created an attachment (id=8777)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=8777&action=view)
C file causing the ICE


-- 


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


[Bug target/21323] New: internal compiler error: Segmentation fault

2005-05-01 Thread matt at 3am-software dot com
g., t2) at
0x1203682f4.
During symbol reading, incomplete CFI data; unspecified registers (e.g., t3) at
0x1203682f4.
During symbol reading, incomplete CFI data; unspecified registers (e.g., t4) at
0x1203682f4.
During symbol reading, incomplete CFI data; unspecified registers (e.g., t5) at
0x1203682f4.
During symbol reading, incomplete CFI data; unspecified registers (e.g., t6) at
0x1203682f4.
During symbol reading, incomplete CFI data; unspecified registers (e.g., t7) at
0x1203682f4.
During symbol reading, incomplete CFI data; unspecified registers (e.g., a0) at
0x1203682f4.
During symbol reading, incomplete CFI data; unspecified registers (e.g., a1) at
0x1203682f4.
During symbol reading, incomplete CFI data; unspecified registers (e.g., a2) at
0x1203682f4.
During symbol reading, incomplete CFI data; unspecified registers (e.g., a3) at
0x1203682f4.
During symbol reading, incomplete CFI data; unspecified registers (e.g., a4) at
0x1203682f4.
During symbol reading, incomplete CFI data; unspecified registers (e.g., a5) at
0x1203682f4.
During symbol reading, incomplete CFI data; unspecified registers (e.g., t8) at
0x1203682f4.
During symbol reading, incomplete CFI data; unspecified registers (e.g., t9) at
0x1203682f4.
During symbol reading, incomplete CFI data; unspecified registers (e.g., t10) at
0x1203682f4.
During symbol reading, incomplete CFI data; unspecified registers (e.g., t11) at
0x1203682f4.
0x120547b00, flags=0) at /u1/toolchain/gcc/gcc/loop.c:6344
6344  rtx test_reg = gen_rtx_REG (word_mode, LAST_VIRTUAL_REGISTER + 1);
(gdb) t
[Current thread is 0 (process 9767)]
(gdb) where
#0  strength_reduce (loop=0x120547b00, flags=0)
at /u1/toolchain/gcc/gcc/loop.c:6344
#1  0x00012036df34 in loop_optimize (f=, 
dumpfile=, flags=0)
at /u1/toolchain/gcc/gcc/loop.c:1565
During symbol reading, incomplete CFI data; unspecified registers (e.g., v0) at
0x12036bd9c.
#2  0x0001202dfc2c in rest_of_handle_loop_optimize ()
at /u1/toolchain/gcc/gcc/passes.c:
#3  0x0001202e1b04 in rest_of_compilation ()
at /u1/toolchain/gcc/gcc/passes.c:1574
#4  0x00012007b670 in execute_pass_list (pass=0x120473e58)
at /u1/toolchain/gcc/gcc/tree-optimize.c:578
#5  0x00012007bacc in tree_rest_of_compilation (fndecl=0x1608d11e0)
at /u1/toolchain/gcc/gcc/tree-optimize.c:728
#6  0x00012001242c in c_expand_body (fndecl=0x1608d11e0)
at /u1/toolchain/gcc/gcc/c-decl.c:6411
#7  0x000120307c08 in cgraph_expand_function (node=0x1608da8f0)
at /u1/toolchain/gcc/gcc/cgraphunit.c:924
#8  0x000120308924 in cgraph_optimize ()
at /u1/toolchain/gcc/gcc/cgraphunit.c:988
#9  0x000120014bb8 in c_write_global_declarations ()
at /u1/toolchain/gcc/gcc/c-decl.c:7395
#10 0x0001202bc15c in toplev_main (argc=, 
argv=) at /u1/toolchain/gcc/gcc/toplev.c:1013
#11 0x000120066bb8 in main (argc=, 
argv=) at /u1/toolchain/gcc/gcc/main.c:35

-- 
   Summary: internal compiler error: Segmentation fault
   Product: gcc
   Version: 4.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: target
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: matt at 3am-software dot com
CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: alpha--netbsd
  GCC host triplet: alpha--netbsd
GCC target triplet: alpha--netbsd


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


[Bug target/21323] internal compiler error: Segmentation fault

2005-05-01 Thread matt at 3am-software dot com

--- Additional Comments From matt at 3am-software dot com  2005-05-01 22:18 
---
Created an attachment (id=8786)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=8786&action=view)
precompile source


-- 


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


[Bug target/21323] internal compiler error: Segmentation fault

2005-05-01 Thread matt at 3am-software dot com

--- Additional Comments From matt at 3am-software dot com  2005-05-01 23:05 
---
4.1.0 was bootstrapping properly using the 20050409 experimental so this is a
relatively recent bug.

-- 


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


[Bug middle-end/21309] internal compiler error: in expand_mult_const, at expmed.c:2884

2005-05-08 Thread matt at 3am-software dot com

--- Additional Comments From matt at 3am-software dot com  2005-05-08 15:32 
---
This bug is to due to struct mult_cost having its member defined as shorts. 
Since MAX_COST is defined to be INT_MAX, when a cost value is moved from div_mod
to mult_cost, the upper bits are truncated and the 0x7fd9 cost becomes
0xffd9. This results is a negative cost and causes a premature to happen in
synth_mult due to:

  if (cost_limit->cost < 0
  || (cost_limit->cost == 0 && cost_limit->latency <= 0))
return;

And so the algorithm fails to be set resulting in the eventual call to
gcc_unreachable.

Simply changing the members of mult_cost from short to int causes the ICE to be
avoided.

--- expmed.c27 Apr 2005 16:02:33 -  1.228
+++ expmed.c8 May 2005 15:32:04 -
@@ -2315,8 +2315,8 @@ enum alg_code { alg_unknown, alg_zero, a
leaves and rtx_cost(op) + max(latency(a), latency(b)) otherwise.  */
 
 struct mult_cost {
-  short cost; /* Total rtx_cost of the multiplication sequence.  */
-  short latency;  /* The latency of the multiplication sequence.  */
+  int cost; /* Total rtx_cost of the multiplication sequence.  */
+  int latency;  /* The latency of the multiplication sequence.  */
 };
 
 /* This macro is used to compare a pointer to a mult_cost against an


-- 
   What|Removed |Added

  Component|target  |middle-end


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


[Bug target/21323] internal compiler error: Segmentation fault

2005-05-18 Thread matt at 3am-software dot com

--- Additional Comments From matt at 3am-software dot com  2005-05-18 21:39 
---
Subject: Re:  internal compiler error: Segmentation fault

rth at gcc dot gnu dot org wrote:
> --- Additional Comments From rth at gcc dot gnu dot org  2005-05-18 06:09 
> ---
> Do you still reproduce this?  I suppose I've not bootstrapped with anything
> other than alphaev67 in a while, so this might be an ev4 bug...

Yep, it still happens.  This is on an XP1000.

./xgcc -B./ -B/usr/gcc/alpha--netbsd/bin/ -isystem 
/usr/gcc/alpha--netbsd/include -isystem /usr/gcc/alpha--netbsd/sys-include 
-L/u1/toolchain/alpha/gcc/gcc/../ld -O2  -DIN_GCC-W -Wall -Wwrite-strings 
-Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem 
./include  -fPIC -mieee -g  -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED  -I. -I. 
-I/u1/toolchain/gcc/gcc -I/u1/toolchain/gcc/gcc/. 
-I/u1/toolchain/gcc/gcc/../include -I./../intl 
-I/u1/toolchain/gcc/gcc/../libcpp/include  -DL_popcountsi2 -fvisibility=hidden 
-DHIDE_EXPORTS -c /u1/toolchain/gcc/gcc/libgcc2.c -o libgcc/./_popcountsi2.o
/u1/toolchain/gcc/gcc/libgcc2.c: In function '__popcountdi2':
/u1/toolchain/gcc/gcc/libgcc2.c:758: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See http://gcc.gnu.org/bugs.html> for instructions.






-- 


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