diff options
| author | Richard Osborne <richard@xmos.com> | 2013-07-02 14:46:34 +0000 |
|---|---|---|
| committer | Richard Osborne <richard@xmos.com> | 2013-07-02 14:46:34 +0000 |
| commit | e4cc98686af16d2126dc06f6cb6cafd13e89e675 (patch) | |
| tree | 049d0e821ec8196239e127b9408ccf25feec2479 | |
| parent | 24bb46bc6684b38a5fc12ad2baebc30436002182 (diff) | |
| download | bcm5719-llvm-e4cc98686af16d2126dc06f6cb6cafd13e89e675.tar.gz bcm5719-llvm-e4cc98686af16d2126dc06f6cb6cafd13e89e675.zip | |
[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.
llvm-svn: 185430
| -rw-r--r-- | llvm/lib/Target/XCore/XCoreISelDAGToDAG.cpp | 2 | ||||
| -rw-r--r-- | llvm/lib/Target/XCore/XCoreInstrInfo.td | 2 | ||||
| -rw-r--r-- | llvm/test/CodeGen/XCore/constants.ll | 8 | ||||
| -rw-r--r-- | llvm/test/CodeGen/XCore/zext.ll | 10 |
4 files changed, 20 insertions, 2 deletions
diff --git a/llvm/lib/Target/XCore/XCoreISelDAGToDAG.cpp b/llvm/lib/Target/XCore/XCoreISelDAGToDAG.cpp index 768cba6dee0..e28f84fec2a 100644 --- a/llvm/lib/Target/XCore/XCoreISelDAGToDAG.cpp +++ b/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); } diff --git a/llvm/lib/Target/XCore/XCoreInstrInfo.td b/llvm/lib/Target/XCore/XCoreInstrInfo.td index e06419ac188..be152aee928 100644 --- a/llvm/lib/Target/XCore/XCoreInstrInfo.td +++ b/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, [{ diff --git a/llvm/test/CodeGen/XCore/constants.ll b/llvm/test/CodeGen/XCore/constants.ll index cad1a2153f4..1e064f37bac 100644 --- a/llvm/test/CodeGen/XCore/constants.ll +++ b/llvm/test/CodeGen/XCore/constants.ll @@ -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; +} diff --git a/llvm/test/CodeGen/XCore/zext.ll b/llvm/test/CodeGen/XCore/zext.ll new file mode 100644 index 00000000000..32abfcaed10 --- /dev/null +++ b/llvm/test/CodeGen/XCore/zext.ll @@ -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 +} |

