xcore backend: bug when calling countLeadingZeros()
Duncan Sands
duncan.sands at gmail.com
Tue Jul 2 11:46:47 PDT 2013
On 02/07/13 19:03, Robert Lytton wrote:
>
> Hi Duncan,
>
> I've looked through LLVM and clang code.
> All other calls to countLeadingZeros(VALUE) are correct - from reasoning the code.
Thanks for doing this Robert. Your patch looks good to me.
Ciao, Duncan.
>
> robert
>
> ________________________________________
> From: llvm-commits-bounces at cs.uiuc.edu [llvm-commits-bounces at cs.uiuc.edu] on behalf of Robert Lytton [robert at xmos.com]
> Sent: 02 July 2013 16:08
> To: Duncan Sands; llvm-commits at cs.uiuc.edu
> Subject: RE: xcore backend: bug when calling countLeadingZeros()
>
> Hi Duncan,
>
> I've not audited the entire code base - sorry.
> I'll take a look this evening and let you know....
>
> Robert
>
> ________________________________________
> From: llvm-commits-bounces at cs.uiuc.edu [llvm-commits-bounces at cs.uiuc.edu] on behalf of Duncan Sands [duncan.sands at gmail.com]
> Sent: 02 July 2013 14:45
> To: llvm-commits at cs.uiuc.edu
> Subject: Re: xcore backend: bug when calling countLeadingZeros()
>
> Hi Robert,
>
> On 02/07/13 14:51, Robert Lytton wrote:
>> Hi,
>>
>> commit b955b0de : "Replace Count{Leading,Trailing}Zeros_{32,64} with
>> count{Leading,Trailing}Zeros"
>> Added bug to XCore backend.
>>
>> The type past to countLeadingZeros() now needs to be explicitly cast to 32bit
>
> are other uses of these routines OK? Did you audit the entire codebase?
>
> Thanks, Duncan.
>
>>
>> Below is the patch:
>> llvm/lib/Target/XCore/XCoreISelDAGToDAG.cpp
>> llvm/lib/Target/XCore/XCoreInstrInfo.td
>> and test:
>> llvm/test/CodeGen/XCore/zext.ll
>>
>> robert
>>
>>
>> --- llvm/lib/Target/XCore/XCoreISelDAGToDAG.cpp
>> +++ llvm/lib/Target/XCore/XCoreISelDAGToDAG.cpp
>> @@ -115,7 +115,7 @@ SDNode *XCoreDAGToDAGISel::Select(SDNode *N) {
>> if (immMskBitp(N)) {
>> // Transformation function: get the size of a mask
>> // Look for the first non-zero bit
>> - SDValue MskSize = getI32Imm(32 - countLeadingZeros(Val));
>> + SDValue MskSize = getI32Imm(32 - countLeadingZeros((uint32_t)Val));
>> return CurDAG->getMachineNode(XCore::MKMSK_rus, dl,
>> MVT::i32, MskSize);
>> }
>>
>>
>> --- llvm/lib/Target/XCore/XCoreInstrInfo.td
>> +++ llvm/lib/Target/XCore/XCoreInstrInfo.td
>> @@ -84,7 +84,7 @@ def msksize_xform : SDNodeXForm<imm, [{
>> // Transformation function: get the size of a mask
>> assert(isMask_32(N->getZExtValue()));
>> // look for the first non-zero bit
>> - return getI32Imm(32 - countLeadingZeros(N->getZExtValue()));
>> + return getI32Imm(32 - countLeadingZeros((uint32_t)N->getZExtValue()));
>> }]>;
>>
>> def neg_xform : SDNodeXForm<imm, [{
>>
>>
>> --- /dev/null
>> +++ llvm/test/CodeGen/XCore/zext.ll
>> @@ -0,0 +1,17 @@
>> +; RUN: llc -march=xcore < %s | FileCheck %s
>> +;; countLeadingZeros() must be past 32bit types
>> +
>> +define i32 @f(i1 %a) {
>> +entry:
>> +; CHECK: zext r0, 1
>> +; CHECK: retsp 0
>> + %b= zext i1 %a to i32
>> + ret i32 %b
>> +}
>> +
>> +define i32 @g() {
>> +entry:
>> +; CHECK: mkmsk r0, 1
>> +; CHECK: retsp 0
>> + ret i32 1;
>> +}
>>
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
More information about the llvm-commits
mailing list