https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106602

--- Comment #21 from Vineet Gupta <vineetg at rivosinc dot com> ---

I've been experimenting with 

(define_predicate "consecutive_bits_operand"
  (match_code "const_int")
{
        unsigned HOST_WIDE_INT val = UINTVAL (op);
        if (exact_log2 ((val >> ctz_hwi (val)) + 1) < 0)
                return false;

        return true;
})

(define_split
  [(set (match_operand:DI 0 "register_operand")
        (and:DI (match_operand:DI 1 "register_operand")
                (match_operand:DI 2 "consecutive_bits_operand")))
   (clobber (match_operand:DI 3 "register_operand"))]
  "TARGET_64BIT"
 [(set (match_dup 3)
       (lshiftrt:DI (match_dup 1) (match_dup 4)))
  (set (match_dup 3)
       (ashift:DI (match_dup 3) (match_dup 5)))
  (set (match_dup 0)
       (lshiftrt:DI (match_dup 3) (match_dup 6)))]
{
  unsigned HOST_WIDE_INT mask = UINTVAL (operands[2]);
  int r = ctz_hwi (mask);
  int l = clz_hwi (mask);
  operands[4] = GEN_INT (r);
  operands[5] = GEN_INT (r+l);
  operands[6] = GEN_INT (l);
})

However 
 try_combine
    recog_for_combine
      recog_for_combine_1
         recog( )

is failing and we get "Failed to recognize..."

(gdb) call debug_rtx(x1)
(set (reg:DI 75)
    (and:DI (reg:DI 76)
        (const_int 274877906880 [0x3fffffffc0])))

I can't step through recog() cpp code since gen* insert #line for md file and
gdb steps through unrelated md code. FWIW cc1 is being built with -g3 -O0

Reply via email to