Why scheduler do not re-emit REG_DEAD notes?

2015-09-07 Thread Konstantin Vladimirov
Hi, In private backend for GCC 5.2.0, we do have target-specific scheduler (running in TARGET_SCHED_FINISH hook), that do some instruction packing/pairing on sched2 and relies on REG_DEAD notes, that should be correct. But they aren't because inside haifa-sched.c, that is being run first in the s

[optimization missed] Why do x86 gcc need extension here?

2015-09-28 Thread Konstantin Vladimirov
Simple test: --- struct U { unsigned s: 1; }; struct V { unsigned short o: 7; unsigned short u: 1; }; extern struct U t[]; extern struct V d[]; unsigned foo () { struct V descr = d[0]; unsigned osize = descr.o; if ( descr.u ) { struct U udata = t[osize];

How to assign proper static_pass_number and recalculate other ones?

2015-10-01 Thread Konstantin Vladimirov
Hi, I am creating my own RTL pass inside private backend (GCC 5.2.0) and I want to register it via register_pass call from override_options hook, to not interfere with platform-independent GCC code. register_pass (new my_cool_rtl_pass (g, "my_cool_pass"), PASS_POS_INSERT_AFTER,

Shallow copy error in scheduler deps?

2015-10-20 Thread Konstantin Vladimirov
Hi, --- sched-int.h --- /* Information about the dependency. */ struct _dep { struct dep_replacement *replace; }; typedef dep_def *dep_t; --- sched-deps.c --- static void copy_dep (dep_t to, dep_t from) { memcpy (to, from, sizeof (*to)); // oops? } This might be source of doubl

Re: Shallow copy error in scheduler deps?

2015-10-22 Thread Konstantin Vladimirov
at 7:52 PM, Jeff Law wrote: > On 10/20/2015 10:06 AM, Konstantin Vladimirov wrote: >> >> Hi, >> >> Inside custom backend, if I do have insn and insn2, insn can be >> deleted when changing insn2, and also all dependencies should be >> preserved. So I did somet

Clarification required about bitfields

2015-12-23 Thread Konstantin Vladimirov
Hi, Now LLVM and GCC essentially disagrees on simple test (minimized from one of dejagnu tests): #include struct s { unsigned long long u33: 33; unsigned long long u40: 40; unsigned long long u41: 41; }; struct s a = { 0x10, 0x10, 0x10 }; int main (void) { if (a.u33 * a.u3

Re: LTO problems with -fprofile-generate (aarch64)

2016-08-30 Thread Konstantin Vladimirov
Hi, I have the same error while compiling complex project with private backend. Are there some patches for this? Some advices where to dig? Context is the following: there is foo that is external and bar.constprop that is internal, but is in foo's comdat list. When add_symbol_to_partitition recu

multilib related question

2015-01-14 Thread Konstantin Vladimirov
Hi, If I want libraries to be built with -A by default and dirb to contain libraries built with -B, I can simply write makefile fragment MULTILIB_OPTIONS = A/B MULTILIB_DIRNAMES= dira dirb And inside machine description: #define MULTILIB_DEFAULTS { "A" } But what if I want little more

Question about vectorization

2015-01-15 Thread Konstantin Vladimirov
Hi, Consider simple test: #include #ifdef FAILV unsigned short* get_aa(void); double* get_bb(void); #else extern unsigned short a[1024]; extern double b[1024]; #endif unsigned short *foo() { size_t i; #ifdef FAILV unsigned short * restrict aa = get_aa(); double * restrict bb

Flags and data mixing problem

2011-08-23 Thread Konstantin Vladimirov
Hi, all Consider architecture, where *any* data register have associated flag field. I.e. any register may be used as a data store to further use, and as a flag keeper to further branch. Do you have any ideas how to utilize this property in GCC machine description? May be any examples of existing

Re: Flags and data mixing problem

2011-08-23 Thread Konstantin Vladimirov
On Tue, Aug 23, 2011 at 12:32 PM, Richard Henderson wrote: > On 08/23/2011 12:18 PM, Konstantin Vladimirov wrote: >> Hi, >> >> Register may at the same time hold data and flags for branch, and live >> range for data and for flags may be different -- they are totally &

Inline assembler + register values

2012-01-24 Thread Konstantin Vladimirov
Hi, This problem is backend independent, so I build reproduction in x86 backend. Consider code: int func(int x); int test(int x, int *data) { int retval; register int *buffer asm ("eax"); buffer = data; retval = func(x); __asm__ __volatile__ (".internal_label _t." "4096"

why GCC does implicit promotion to unsigned char?

2012-01-26 Thread Konstantin Vladimirov
Hi, Consider code: char A; char B; char sum_A_B ( void ) { char sum = A + B; return sum; } Compile it on any backend (for example x86): gcc (SUSE Linux) 4.5.0 20100604 [gcc-4_5-branch revision 160292] gcc -m32 -O2 -S repro.c -fdump-tree-all-lineno-details Now look at repro.c.004t.gimple

Re: why GCC does implicit promotion to unsigned char?

2012-01-26 Thread Konstantin Vladimirov
Jelinek wrote: > On Thu, Jan 26, 2012 at 02:27:45PM +0400, Konstantin Vladimirov wrote: >> Consider code: >> >> char A; >> char B; >> >> char sum_A_B ( void ) >> { >>   char sum = A + B; >> >>   return sum; >> } >>   [repro.c :

weird optimization in sin+cos, x86 backend

2012-02-03 Thread Konstantin Vladimirov
Hi, Consider minimal reproduction code: #include "math.h" #include "stdio.h" double __attribute__ ((noinline)) slip(double a) { return (cos(a) + sin(a)); } int main(void) { double a = 4.47460300787e+182; double slipped = slip(a); printf("slipped = %lf\n", slipped); return 0; } Compil

Re: weird optimization in sin+cos, x86 backend

2012-02-03 Thread Konstantin Vladimirov
Hi, I agree, that this case have no practical value. It was autogenerated between other thousands of tests and showed really strange results, so I decided to ask. I thought, this value fits double precision range and, according to C standard, all double-precision arithmetics must be avaliable for

lto pseudo-object files and fixed registers

2012-02-07 Thread Konstantin Vladimirov
Hi, Consider some project, consisting of files: a.c, b.c, d.c and e.c Compiler is gcc 4.6.2 Files a.c and b.c are performance bottlenecks and requires heavy cross-module inline, so must be compiled with -flto option Files d.c and e.c is preffered to be compiled with lto option too, but they are

Re: lto pseudo-object files and fixed registers

2012-02-07 Thread Konstantin Vladimirov
st regards, Konstantin On Tue, Feb 7, 2012 at 4:37 PM, Richard Guenther wrote: > On Tue, Feb 7, 2012 at 1:26 PM, Konstantin Vladimirov > wrote: >> Hi, >> >> Consider some project, consisting of files: a.c, b.c, d.c and e.c >> >> Compiler is gcc 4.6.2 >>

Re: lto pseudo-object files and fixed registers

2012-02-07 Thread Konstantin Vladimirov
Hi, Thanks so much, this exactly solves issue. I didn't know about this option, it seems very useful in such cases. --- With best regards, Konstantin On Tue, Feb 7, 2012 at 5:11 PM, Richard Guenther wrote: > On Tue, Feb 7, 2012 at 1:57 PM, Konstantin Vladimirov > wrote: >>

Question about Os, O2 and duplicating code

2013-04-10 Thread Konstantin Vladimirov
Hi, I have this problem in private backend, but it is reproducible on x86-gcc also, so I suppose core GCC probems. Lets consider simple example: unsigned int buffer[10]; __attribute__((noinline)) void myFunc(unsigned int a, unsigned int b, unsigned int c) { unsigned int tmp; if( a & 0x2 )

Are there an option to pass assembler option to lto wrapper?

2013-04-11 Thread Konstantin Vladimirov
Hi, When I am running: gcc -Wa,--some-custom-option everything is ok. But when I am running: gcc -flto -Wa,--some-custom-option then this option is not passed to assembler, when lto wrapper calls it. I need somehow pass this option to every assembler call, including calls under LTO. I am won

GCC reuses stack slot in setjmp-calling function -- is it a bug or feature?

2013-04-15 Thread Konstantin Vladimirov
Hi, Minimal reproduction for x86: #include #include #include jmp_buf something_happened; int key_gdata = 2; int store_data; void __attribute__((noinline)) initiate(void) { longjmp(something_happened, 1); } int __attribute__ ((noinline)) foo(int x) { return x + 1; } int __attribute__((

Strange optimization in GCC 4.7.2

2013-07-23 Thread Konstantin Vladimirov
Hi, Simple code: void somehowuse(unsigned value); void foo( unsigned value, unsigned bytemask, unsigned psw, unsigned y) { unsigned x; psw = (psw & ~(1 << 10)) | (((value >> 9) & 1) << 10); x = (y & ~(1 << 7)) | (((value >> 9) & 1) << 7); somehowuse(x); somehowuse(psw); } Compile to assemble

Re: Strange optimization in GCC 4.7.2

2013-07-23 Thread Konstantin Vladimirov
Hi, But this is awfully wrong. In the general case (value >> 2) & 0xff != (value >> 2) & 0x80 Take value to be 0x3ff for example. Then 0xff != 0x80 itself. This leads to wrong result. --- With best regards, Konstantin On Tue, Jul 23, 2013 at 4:57 PM, David Given wrote: >

Re: Strange optimization in GCC 4.7.2

2013-07-23 Thread Konstantin Vladimirov
n > > On Tue, Jul 23, 2013 at 4:57 PM, David Given wrote: >> Konstantin Vladimirov wrote: >> [...] >>> x = (y & ~(1 << 7)) | (((value >> 9) & 1) << 7); >> [...] >>> x = y & 4294967167 | (value >> 9) << 7 & 255; &l

assign_parm_find_data_types question

2013-08-15 Thread Konstantin Vladimirov
Hi, In GCC 4.7.2 in function.c, inside assign_parm_find_data_types there is distinction between passed and nominal mode. nominal_type = TREE_TYPE (parm); passed_type = DECL_ARG_TYPE (parm); Next data->passed_pointer is set to true if passed_type should pass by reference. Consider synthetic code

How can I tune gcc to move up simple common subexpression?

2013-11-08 Thread Konstantin Vladimirov
Hi, Consider simple code: typedef struct { unsigned prev; unsigned next; } foo_t; void foo( unsigned x, unsigned y) { foo_t *ptr = (foo_t *)((void *)x); if (y != 0) { ptr->prev = y; ptr->next = x; } else { ptr->prev = 0; /* or ex

x86 gcc lacks simple optimization

2013-12-06 Thread Konstantin Vladimirov
Hi, Consider code: int foo(char *t, char *v, int w) { int i; for (i = 1; i != w; ++i) { int x = i << 2; v[x + 4] = t[x + 4]; } return 0; } Compile it to x86 (I used both gcc 4.7.2 and gcc 4.8.1) with options: gcc -O2 -m32 -S test.c You will see loop, formed like: .L5: leal 0(,%eax,4), %edx

Re: x86 gcc lacks simple optimization

2013-12-06 Thread Konstantin Vladimirov
Dec 6, 2013 at 1:27 PM, David Brown wrote: > On 06/12/13 09:30, Konstantin Vladimirov wrote: >> Hi, >> >> Consider code: >> >> int foo(char *t, char *v, int w) >> { >> int i; >> >> for (i = 1; i != w; ++i) >> { >> int x = i &

Re: x86 gcc lacks simple optimization

2013-12-06 Thread Konstantin Vladimirov
3 at 9:30 AM, Konstantin Vladimirov > wrote: >> Hi, >> >> Consider code: >> >> int foo(char *t, char *v, int w) >> { >> int i; >> >> for (i = 1; i != w; ++i) >> { >> int x = i << 2; >> v[x + 4] = t[x + 4]; >> }

Re: x86 gcc lacks simple optimization

2013-12-06 Thread Konstantin Vladimirov
wrote: > On Fri, Dec 6, 2013 at 11:19 AM, Konstantin Vladimirov > wrote: >> Hi, >> >> nothing changes if everything is unsigned and we are guaranteed to not >> raise UB on overflow: >> >> unsigned foo(unsigned char *t, unsigned char *v, unsigned w) >>

Multiple cc's, one gcc -- is it possible?

2014-04-17 Thread Konstantin Vladimirov
Hi, I want to support, say arch1 and arch2 in custom gcc in the way gcc -march1 test.c calls ${INSTALL}/libexec/gcc/arch1/4.8.2/cc1 and gcc -march2 test.c calls ${INSTALL}/libexec/gcc/arch2/4.8.2/cc1 Are there any way to do it? Maybe not exactly as I outlined, but the whole idea is clear,

How to suppress frame pointer usage by default?

2012-02-21 Thread Konstantin Vladimirov
Hi, What one must use in custom backend to suppress frame pointer usage by default? Frame pointer is mentioned in ELIMINABLE_REGS: #define ELIMINABLE_REGS \ { \ {ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \ {ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM}, \ {FRAME_POIN

register renaming issue

2012-03-01 Thread Konstantin Vladimirov
Hi, I am supporting custom 32-bit backend for gcc 4.6.2, and I want to implement DI to DF conversion. Earlier it was through libgcc. Specific of backend is, that DF may be represented as one register, but source DI must be splitted into two SI to be used. So overall insn pattern (actual splitting

Re: Conditional sibcalls?

2013-02-21 Thread Konstantin Vladimirov
Hi, Sorry, mistyped. Please read `jne` instead of `je` in handwritten "optimized" assembler. --- With best regards, Konstantin On Thu, Feb 21, 2013 at 3:57 PM, Konstantin Vladimirov wrote: > Hi, > > Discovered this optimization possibilty on private backend, but can > e