Skip to content

Commit 35c2a1c

Browse files
committed
Final instruction scheduling & testing
1 parent 94a5538 commit 35c2a1c

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

jsrc/j.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1418,7 +1418,7 @@ if(likely(!((I)jtinplace&JTWILLBEOPENED)))z=EPILOGNORET(z); RETF(z); \
14181418
// in this version one value is always written to shape
14191419
#define GACOPYSHAPE(name,type,atoms,rank,shaape) {I *_s=(I*)(shaape); I *_d=AS(name); *_d=*_s; I _r=1-(rank); NOUNROLL do{_s+=SGNTO0(_r); _d+=SGNTO0(_r); *_d=*_s;}while(++_r<0);}
14201420
#endif
1421-
#define GACOPY1(name,type,atoms,rank,shaape) {I *_d=AS(name); UI _r=(rank); NOUNROLL do{*_d++=1;}while(--_r);} // copy all 1s to shape - rank must not be 0
1421+
#define GACOPY1(name,type,atoms,rank,shaape) {UI _r=(rank); NOUNROLL do{AS(name)[_r-1]=1;}while(--_r);} // copy all 1s to shape - rank must not be 0
14221422

14231423
// GAE executes the given expression when there is an error
14241424
#if SY_64

jsrc/va2.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,30 +44,32 @@ static NOINLINE I intforD(J jt, D d){D q;I z; // noinline because it uses so ma
4444
// we know that AN=1 in a and w, which are FL/INT/B01 types. af is larger arg rank (=rank of result)
4545
// obsolete I awip=2*SGNTO0(AC(a))+SGNTO0(AC(w)); awip=(awip&(I)jtinplace)+4*((I)jtinplace&3); // abandoned flags from aw; make (assignable),(inplaceable) flags
4646
// obsolete z=jtssingleton(jt,a,w,af+((I)FAV(self)->lu2.lc<<RANKTX)+(awip<<16)+((3*(at>>INTX)+(wt>>INTX))<<20)); // create portmanteau parm reg
47-
INLINE static A jtssingleton(J jt,A a,A w,I af,I at, I wt,A self){
47+
INLINE static A jtssingleton(J jt,A a,A w,I af,I at,I wt,A self){
4848
// obsolete A INLINE jtssingleton(J jt, A a,A w,I ipcaserank){A z;I aiv;void *zv;
4949
I awip=2*SGNTO0(AC(a))+SGNTO0(AC(w)); // collect inplaceable status for a and w
5050
I opcode=(I)FAV(self)->lu2.lc; // fetch operation#
51-
void *av=voidAV(a), *wv=voidAV(w); // point to the argument values
5251
I jtinplace=(I)jt; jt=(J)(intptr_t)((I)jt&~JTFLAGMSK); // save jt as an I, clear low bits
5352
// obsolete I zomb=2*(a==jt->zombieval)+(w==jt->zombieval); // see if either arg is being assigned
54-
A zombv=jt->zombieval; // fetch address of assignand
53+
A z=jt->zombieval; // fetch address of assignand, which we presumptively make the result
54+
void *av=voidAV(a), *wv=voidAV(w), *zv; // point to the argument values and result
5555
I caseno=(opcode&0x7f)-VA2CBW1111; caseno=caseno<0?0:caseno; caseno=SSINGCASE(caseno,SSINGENC(at,wt)); // case # for eventual switch. Lump all Booleans at 0
56-
A z=0; void *zv; // pointer to result location
5756
// if the operation is a rank-0 comparison that can return num[result], don't bother with inplacing. Inplacing would be
5857
// a potential gain if the result can itself be inplaced, but it is a certain loser when deciding where the result is
59-
if((opcode>>7)>af)goto nozv; // true if 0x80 (comparison op) and af=0
58+
if((opcode>>7)>af){z=0; goto nozv;} // true if 0x80 (comparison op) and af=0. Set z=0 as a flag to return num(result)
6059
// See if we can inplace. We let some chances get away because they aren't worth testing for. There are two main possibilities: assignment (checked above)
6160
// and abandoned arg (checked presently). If either passes, it must further be not VIRTUAL if assigned (lest it overwrite the backer of a virtual x/y arg)
62-
// and not AFRO if bare; and never UNINCORPABLE since we may change the type and we don't want callers to bear the burden of checking that. It is possible that
63-
// one arg would be inplaceable as an assignment and the other as abandoned, but we pick one and live with it.
64-
if(awip&=jtinplace){z=awip&JTINPLACEW?w:a; if(likely((AFLAG(z)&AFUNINCORPABLE+AFRO)+(af^AR(z))==0))goto getzv;} // block is abandoned inplaceable, not disallowed and correct rank: inplace to it. Priority to w
61+
// and not AFRO if bare; and never UNINCORPABLE since we may change the type and we don't want callers to bear the burden of checking that. Assign in place is best,
62+
// because it makes the assignment skip the free
6563
// See if we can inplace an assignment. That is always a good idea, though rare
66-
if(unlikely((2*(a==zombv)+(w==zombv))&jtinplace)){ // one of the args is being reassigned
67-
if(likely((AFLAG(zombv)&AFVIRTUAL+AFUNINCORPABLE)+(af^AR(zombv))==0)){z=zombv; goto getzv;} // mustn't modify VIRTUAL or INCORPABLE, and reassigned value must have the higher rank
64+
if(unlikely((2*(a==z)+(w==z))&jtinplace)){ // one of the args is being reassigned
65+
if(likely((AFLAG(z)&AFVIRTUAL+AFUNINCORPABLE)+(af^AR(z))==0)){goto getzv;} // mustn't modify VIRTUAL or INCORPABLE, and reassigned value must have the higher rank
6866
// obsolete if(likely(af==AR(jt->zombieval))){z=jt->zombieval; goto getzv;} // the
6967
// obsolete }
7068
}
69+
if(awip&=jtinplace){z=awip&JTINPLACEW?w:a; // block is abandoned inplaceable, : pick it. Priority to w
70+
if(likely((AFLAG(z)&AFUNINCORPABLE+AFRO)+(af^AR(z))==0))goto getzv; // not disallowed and correct rank: use it
71+
if(awip==3){z=a; if(likely((AFLAG(a)&AFUNINCORPABLE+AFRO)+(af^AR(a))==0))goto getzv;} // if a & w both eligible, check a if w failed
72+
}
7173
// obsolete awip&=jtinplace; z=awip&JTINPLACEA?a:z; z=awip&JTINPLACEW?w:z; // block is contextually inplaceable and inplaceable by count= abandoned. Give priority to w
7274
#if 0 // obsolete
7375
// if the operation is a rank-0 comparison that can return num[result], don't bother with inplacing. Inplacing would be
@@ -87,7 +89,7 @@ INLINE static A jtssingleton(J jt,A a,A w,I af,I at, I wt,A self){
8789
#endif
8890
// obsolete if(z&&likely(!(AFLAG(z)&AFUNINCORPABLE+AFRO)))if(likely(af==AR(z)))goto getzv; // not disallowed and correct rank, take it
8991
// fall through: no inplacing, allocate the result, usually an atom. If not atom, make the shape all 1s
90-
if(likely(af==0)){GAT0(z,FL,1,0); zv=voidAV0(z);}else{GATV1(z,FL,1,af); zv=voidAV(z);} // not voidAVn so that af is not needed
92+
if(likely(af==0)){GAT0(z,FL,1,0); zv=voidAV0(z);}else{GATV1(z,FL,1,af); zv=voidAVn(af,z);} // af persists over call
9193
goto nozv;
9294
getzv:; // here when we are operating inplace on z
9395
zv=voidAV(z); // get addr of value

0 commit comments

Comments
 (0)