[llvm] r177296 - Fix 80-col. violations in PPCCTRLoops

Jakob Stoklund Olesen stoklund at 2pi.dk
Mon Mar 18 18:57:56 PDT 2013


On Mar 18, 2013, at 5:04 PM, Hal Finkel <hfinkel at anl.gov> wrote:

> ----- Original Message -----
>> From: "Sean Silva" <silvas at purdue.edu>
>> To: "Hal Finkel" <hfinkel at anl.gov>
>> Cc: llvm-commits at cs.uiuc.edu
>> Sent: Monday, March 18, 2013 6:41:39 PM
>> Subject: Re: [llvm] r177296 - Fix 80-col. violations in PPCCTRLoops
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> + int64_t count = ImmVal -
>> + int64_t(short(DefInstr->getOperand(1).getImm()));
>> 
>> 
>> 
>> This piece of code is confusing. Why is it casting to `short`? If it
>> just doing it to mask to 16-bit, I'd rather see that done explicitly
>> with `& 0xFFFF` instead of assuming that the host's `short` is 16
>> bits.
> 
> It is doing that so that the immediate value is explicitly sign-extended (as a signed short to a signed int64_t). Is there a better way? Otherwise, I can certainly add a comment.

We have code like that in many places, but for clarity: SignExtend64<16>(DefInstr->getOperand(1).getImm())

/jakob





More information about the llvm-commits mailing list