[llvm] r188540 - [SystemZ] Fix handling of 64-bit memcmp results

Richard Sandiford rsandifo at linux.vnet.ibm.com
Mon Aug 19 03:13:02 PDT 2013


Eli Friedman <eli.friedman at gmail.com> writes:
> On Fri, Aug 16, 2013 at 3:55 AM, Richard Sandiford <
> rsandifo at linux.vnet.ibm.com> wrote:
>> Author: rsandifo
>> Date: Fri Aug 16 05:55:47 2013
>> New Revision: 188540
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=188540&view=rev
>> Log:
>> [SystemZ] Fix handling of 64-bit memcmp results
>>
>>
>>
> Why?  memcmp is defined to return "int".

Well, the existing code has:

  // Verify that the prototype makes sense.  int memcmp(void*,void*,size_t)
  if (I.getNumArgOperands() != 3)
    return false;

  const Value *LHS = I.getArgOperand(0), *RHS = I.getArgOperand(1);
  if (!LHS->getType()->isPointerTy() || !RHS->getType()->isPointerTy() ||
      !I.getArgOperand(2)->getType()->isIntegerTy() ||
      !I.getType()->isIntegerTy())
    return false;

and coped with all integer types, so I thought the new optimisation
should do the same for consistency.

If that kind of resillience isn't wanted then should be the above just
be an assert instead?  It seems inconsistent to say that we "know" the
result is int-sized, but check whether the result is even integer-typed.

Richard




More information about the llvm-commits mailing list