cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

realhet
Miniboss

In s_cmp_lg_i32 what LG stands for?

Hi,

I just wonder how comes this abbreviation in the GCN ISA.

In the manual it also mentions that it should be NotEqual. -> S_CMP_{EQ,NE,GT,GE,LE,LT}_{I32,U32}

But when it comes to the section where the details for each instructions are, then it says about LG instead of NE.

Another interesting thing is, that every v_cmp instruction has it's negated twin: for example there is

v_cmp_lg_f32   //D(sgpr).u = (S0 <> S1), signal on sNaN input only; D = VCC in VOPC

and also

v_cmp_neq_f32  //D(sgpr).u = !(S0 == S1), signal on sNaN input only; D = VCC in VOPC

It seems like both of them are for the same thing, but they have different machine codes. Anyone knows why?

0 Likes
4 Replies

Do you know the execution time for these two?(in clock cycles)

0 Likes

(total execution time is 4 cycle. But if you put a scalar instruction after those, then that's an additional 16 cycle penalty.)

0 Likes
drallan
Challenger


realhet wrote:



Hi,



I just wonder how comes this abbreviation in the GCN ISA.


In the manual it also mentions that it should be NotEqual. -> S_CMP_{EQ,NE,GT,GE,LE,LT}_{I32,U32}


But when it comes to the section where the details for each instructions are, then it says about LG instead of NE.



Another interesting thing is, that every v_cmp instruction has it's negated twin: for example there is


v_cmp_lg_f32   //D(sgpr).u = (S0 <> S1), signal on sNaN input only; D = VCC in VOPC


and also


v_cmp_neq_f32  //D(sgpr).u = !(S0 == S1), signal on sNaN input only; D = VCC in VOPC


It seems like both of them are for the same thing, but they have different machine codes. Anyone knows why?


1. The NE in the S_CMP_ list must be a typo. "NE" is not used anywhere in 3 versions of the manual except this example.

2. Interesting question.. One reason, it is required by the IEEE 754 spec for floating point. Quote

"Implementations that provide predicates shall provide the first six predicates in Table 4 and should provide the seventh, and a means of logically negating predicates." (predicates refers to the various equality operators.)

They have an additional footnote about the negated versions,

[FOOTNOTE 6: There may appear to be two ways to write the logical negation of a predicate, one using NOT explicitly and the other reversing the relational operator. For example, the logical negation of (X = Y) may be written either NOT(X = Y) or (X ?<> Y); in this case both expressions are functionally equivalent to (X != Y). However, this coincidence does not occur for the other predicates. For example, the logical negation of (X < Y) is just NOT(X < Y); the reversed predicate (X ?>= Y) is different in that it does not signal an invalid operation exception when X and Y are unordered.]

Finally popped into my mind that LG probably means [Less or Greater]. It almost took me 2 weeks, though.