This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: Add SSE4.2 support - pcmpstr part


H. J. Lu wrote:

Also, I see no reason, why we need two new CC modes. CCmode mode is
enough to use as a generic comparison mode.

The new CC modes are due to __builtin_ia32_pcmp?str?o128, which
checks OF bit, and __builtin_ia32_pcmp?str?s128, which checks SF
bit. Those aren't covered by the normal CC modes. There are no
RTX codes for them. That is I invented 2 modes and reuse UNGT/UNLT.
Besides you can't mix CC modes set by __builtin_ia32_pcmpistr?o128
and __builtin_ia32_pcmpestr?o128 since they work on different things.

This part is a bit tricky. You propose:


- Add CCZ to indicate that only the Zero flag is valid. */
+ Add CCZ to indicate that only the Zero flag is valid.
+
+ Add CCPCMPESTR/CCPCMPISTR for pcmp[ei]str[im] instructions:
+ + suffix rtx_code
+ a GTU
+ c LTU
+ o UNGT OF == 1
+ s UNLT SF == 1
+ z EQ
+ */

But please note, that RTX code (that is present in the CC consumer) produces correct Jcc/SETcc insn only in combination with the mode of the CC register. We could re-write the table above according to existing suffixes from put_condition_code():


suffix        RTX code      mode
  a             GTU         CC
  c             LTU         CC
  o             EQ          CCO   (*)
  s             EQ          CCS   (*)
  z             EQ          CCZ

So, we currently have no mode that could generate "o" or "s" suffix, i.e "seto" or "jo".

Builtin expander should then generate pcmp?str pattern with correct CCmode and CC consumer with correct comparison code in correct mode. Like for example in following code:

--cut here--
int test(int a)
{
 if (a < 0)
   func1();
 else
   func2();
}
--cut here--

that expands to:
--cut here--
(insn 6 5 7 cc.c:3 (set (reg:CCGOC 17 flags)
       (compare:CCGOC (reg/v:SI 59 [ a ])
           (const_int 0 [0x0]))) -1 (nil)
   (nil))

(jump_insn 7 6 0 cc.c:3 (set (pc)
       (if_then_else (ge (reg:CCGOC 17 flags)
               (const_int 0 [0x0]))
           (label_ref 0)
           (pc))) -1 (nil)
   (expr_list:REG_BR_PROB (const_int 7326 [0x1c9e])
       (nil)))
--cut here--

Uros.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]