From 3139db02c8cdf83a71f04a9aeb4e295031b1e57c Mon Sep 17 00:00:00 2001 From: Robert Lytton Date: Fri, 11 Oct 2013 10:26:29 +0000 Subject: [PATCH] XCore target: add XCoreTargetLowering::isZExtFree() llvm-svn: 192431 --- llvm/lib/Target/XCore/XCoreISelLowering.cpp | 18 ++++++++++++++++++ llvm/lib/Target/XCore/XCoreISelLowering.h | 4 ++++ llvm/test/CodeGen/XCore/zextfree.ll | 15 +++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 llvm/test/CodeGen/XCore/zextfree.ll diff --git a/llvm/lib/Target/XCore/XCoreISelLowering.cpp b/llvm/lib/Target/XCore/XCoreISelLowering.cpp index e209c29522d0..489f0a7244cb 100644 --- a/llvm/lib/Target/XCore/XCoreISelLowering.cpp +++ b/llvm/lib/Target/XCore/XCoreISelLowering.cpp @@ -166,6 +166,24 @@ XCoreTargetLowering::XCoreTargetLowering(XCoreTargetMachine &XTM) setMinFunctionAlignment(1); } +bool XCoreTargetLowering::isZExtFree(SDValue Val, EVT VT2) const { + if (Val.getOpcode() != ISD::LOAD) + return false; + + EVT VT1 = Val.getValueType(); + if (!VT1.isSimple() || !VT1.isInteger() || + !VT2.isSimple() || !VT2.isInteger()) + return false; + + switch (VT1.getSimpleVT().SimpleTy) { + default: break; + case MVT::i8: + return true; + } + + return false; +} + SDValue XCoreTargetLowering:: LowerOperation(SDValue Op, SelectionDAG &DAG) const { switch (Op.getOpcode()) diff --git a/llvm/lib/Target/XCore/XCoreISelLowering.h b/llvm/lib/Target/XCore/XCoreISelLowering.h index 7761b7cef6b1..2a6c8748cd68 100644 --- a/llvm/lib/Target/XCore/XCoreISelLowering.h +++ b/llvm/lib/Target/XCore/XCoreISelLowering.h @@ -83,6 +83,10 @@ namespace llvm { explicit XCoreTargetLowering(XCoreTargetMachine &TM); + using TargetLowering::isZExtFree; + virtual bool isZExtFree(SDValue Val, EVT VT2) const; + + virtual unsigned getJumpTableEncoding() const; virtual MVT getScalarShiftAmountTy(EVT LHSTy) const { return MVT::i32; } diff --git a/llvm/test/CodeGen/XCore/zextfree.ll b/llvm/test/CodeGen/XCore/zextfree.ll new file mode 100644 index 000000000000..48dce8865328 --- /dev/null +++ b/llvm/test/CodeGen/XCore/zextfree.ll @@ -0,0 +1,15 @@ +; RUN: llc -march=xcore < %s | FileCheck %s + +; CHECK-LABEL: test: +; CHECK-NOT: zext +define void @test(i8* %s1) { +entry: + %u8 = load i8* %s1, align 1 + %bool = icmp eq i8 %u8, 0 + br label %BB1 +BB1: + br i1 %bool, label %BB1, label %BB2 +BB2: + br i1 %bool, label %BB1, label %BB2 +} +