This is the mail archive of the gcc-bugs@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]

[Bug target/53399] New: "*ffs" pattern generates wrong code with BMI enabled (for corner cases)


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53399

             Bug #: 53399
           Summary: "*ffs" pattern generates wrong code with BMI enabled
                    (for corner cases)
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: kirill.yukhin@intel.com


We have in GCC int. (__ffs description):
These functions return the index of the least significant 1-bit in a, or the
value zero if a is zero.

and in i386.md:
(define_insn "*ffs<mode>_1"
  [(set (reg:CCZ FLAGS_REG)
        (compare:CCZ (match_operand:SWI48 1 "nonimmediate_operand" "rm")
                     (const_int 0)))
   (set (match_operand:SWI48 0 "register_operand" "=r")
        (ctz:SWI48 (match_dup 1)))]
  ""
{
  if (TARGET_BMI)
    return "tzcnt{<imodesuffix>}\t{%1, %0|%0, %1}";
  else 

This pattern works fine for bsf insn (although the result with zero input is
undefined)
But for tzcnt with 0 as input we have (operand_size+1) as output.

That contradicts with GCC int, right?

It also seems to fail gcc.c-torture/execute/builtin-bitops-1.c


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