On Thu, Sep 01, 2022 at 11:04:03AM +0200, FX wrote: > Hi Jakub, > > >> 2. All the functions are available as GCC type-generic built-ins (yeah!), > >> except there is no __builtin_ iseqsig > >> (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77928). Is there a > >> fundamental problem with creating one, and could someone help there? > > > > IMHO until that one is implemented you can just use > > tx = x, ty = y, tx>=ty && tx<=ty > > (in GENERIC just SAVE_EXPR<x> >= SAVE_EXPR<y> && SAVE_EXPR<x> <= > > SAVE_EXPR<y> > > If it’s just that (optimization aside), I probably can create a C built-in. > It would need to be: > > 1. defined in builtins.def > 2. lowered in builtins.cc > 3. type-checked in c-family/c-common.cc > 4. documented in doc/extend.texi > 5. tested in fp-test.cc > 6. covered in the testsuite > > Is that right?
Dunno if we really need a builtin for this, especially if it is lowered to that x >= y && x <= y early, will defer to Joseph. Because if it is for better code generation only, IMNSHO we want to optimize even when users write it that way by hand and so want to pattern recognize that during instruction selection before expansion (isel pass) or during expansion if target can do that. E.g. x86 with AVX can do that: where the 4 booleans are A>B, A<B, A=B, Unordered and Yes/No is whether signal is raised when one or both of the operands are QNaN (it is raised always if at least one is SNaN): EQ_OQ (EQ) 0H Equal (ordered, non-signaling) False False True False No LT_OS (LT) 1H Less-than (ordered, signaling) False True False False Yes LE_OS (LE) 2H Less-than-or-equal (ordered, signaling) False True True False Yes UNORD_Q (UNORD) 3H Unordered (non-signaling) False False False True No NEQ_UQ (NEQ) 4H Not-equal (unordered, non-signaling) True True False True No NLT_US (NLT) 5H Not-less-than (unordered, signaling) True False True True Yes NLE_US (NLE) 6H Not-less-than-or-equal (unordered, signaling) True False False True Yes ORD_Q (ORD) 7H Ordered (non-signaling) True True True False No EQ_UQ 8H Equal (unordered, non-signaling) False False True True No NGE_US (NGE) 9H Not-greater-than-or-equal (unordered, signaling) False True False True Yes NGT_US (NGT) AH Not-greater-than (unordered, signaling) False True True True Yes FALSE_OQ (FALSE) BH False (ordered, non-signaling) False False False False No NEQ_OQ CH Not-equal (ordered, non-signaling) True True False False No GE_OS (GE) DH Greater-than-or-equal (ordered, signaling) True False True False Yes GT_OS (GT) EH Greater-than (ordered, signaling) True False False False Yes TRUE_UQ (TRUE) FH True (unordered, non-signaling) True True True True No EQ_OS 10H Equal (ordered, signaling) False False True False Yes LT_OQ 11H Less-than (ordered, non-signaling) False True False False No LE_OQ 12H Less-than-or-equal (ordered, non-signaling) False True True False No UNORD_S 13H Unordered (signaling) False False False True Yes NEQ_US 14H Not-equal (unordered, signaling) True True False True Yes NLT_UQ 15H Not-less-than (unordered, non-signaling) True False True True No NLE_UQ 16H Not-less-than-or-equal (unordered, non-signaling) True False False True No ORD_S 17H Ordered (signaling) True True True False Yes EQ_US 18H Equal (unordered, signaling) False False True True Yes NGE_UQ 19H Not-greater-than-or-equal (unordered, non-signaling) False True False True No NGT_UQ 1AH Not-greater-than (unordered, non-signaling) False True True True No FALSE_OS 1BH False (ordered, signaling) False False False False Yes NEQ_OS 1CH Not-equal (ordered, signaling) True True False False Yes GE_OQ 1DH Greater-than-or-equal (ordered, non-signaling) True False True False No GT_OQ 1EH Greater-than (ordered, non-signaling) True False False False No TRUE_US 1FH True (unordered, signaling) True True True True Yes So x >= y && x <= y can be handled using vcmpeq_ossd or similar instructions. Jakub