[llvm] r185430 - [XCore] Fix instruction selection for zext, mkmsk instructions.

Richard Osborne richard at xmos.com
Tue Jul 2 07:46:34 PDT 2013


Author: friedgold
Date: Tue Jul  2 09:46:34 2013
New Revision: 185430

URL: http://llvm.org/viewvc/llvm-project?rev=185430&view=rev
Log:
[XCore] Fix instruction selection for zext, mkmsk instructions.

r182680 replaced CountLeadingZeros_32 with a template function
countLeadingZeros that relies on using the correct argument type to give
the right result. The type passed in the XCore backend after this
revision was incorrect in a couple of places.

Patch by Robert Lytton.

Added:
    llvm/trunk/test/CodeGen/XCore/zext.ll
Modified:
    llvm/trunk/lib/Target/XCore/XCoreISelDAGToDAG.cpp
    llvm/trunk/lib/Target/XCore/XCoreInstrInfo.td
    llvm/trunk/test/CodeGen/XCore/constants.ll

Modified: llvm/trunk/lib/Target/XCore/XCoreISelDAGToDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreISelDAGToDAG.cpp?rev=185430&r1=185429&r2=185430&view=diff
==============================================================================
--- llvm/trunk/lib/Target/XCore/XCoreISelDAGToDAG.cpp (original)
+++ llvm/trunk/lib/Target/XCore/XCoreISelDAGToDAG.cpp Tue Jul  2 09:46:34 2013
@@ -115,7 +115,7 @@ SDNode *XCoreDAGToDAGISel::Select(SDNode
     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);
     }

Modified: llvm/trunk/lib/Target/XCore/XCoreInstrInfo.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreInstrInfo.td?rev=185430&r1=185429&r2=185430&view=diff
==============================================================================
--- llvm/trunk/lib/Target/XCore/XCoreInstrInfo.td (original)
+++ llvm/trunk/lib/Target/XCore/XCoreInstrInfo.td Tue Jul  2 09:46:34 2013
@@ -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, [{

Modified: llvm/trunk/test/CodeGen/XCore/constants.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/XCore/constants.ll?rev=185430&r1=185429&r2=185430&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/XCore/constants.ll (original)
+++ llvm/trunk/test/CodeGen/XCore/constants.ll Tue Jul  2 09:46:34 2013
@@ -9,3 +9,11 @@ define i32 @f() {
 entry:
 	ret i32 12345678
 }
+
+define i32 @g() {
+entry:
+; CHECK: g:
+; CHECK: mkmsk r0, 1
+; CHECK: retsp 0
+  ret i32 1;
+}

Added: llvm/trunk/test/CodeGen/XCore/zext.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/XCore/zext.ll?rev=185430&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/XCore/zext.ll (added)
+++ llvm/trunk/test/CodeGen/XCore/zext.ll Tue Jul  2 09:46:34 2013
@@ -0,0 +1,10 @@
+; RUN: llc -march=xcore < %s | FileCheck %s
+
+define i32 @f(i1 %a) {
+entry:
+; CHECK: f
+; CHECK: zext r0, 1
+; CHECK: retsp 0
+  %b= zext i1 %a to i32
+  ret i32 %b
+}





More information about the llvm-commits mailing list