summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2014-05-22 18:09:03 +0000
committerMatt Arsenault <Matthew.Arsenault@amd.com>2014-05-22 18:09:03 +0000
commitbf8694d36d8e7f5a5b459a0fb134e4f84daa6376 (patch)
treea2682dabe5f4d235cad0da22029c147b0735cec0 /llvm/lib/Target
parentaf6df9d94322a32ad1eff9fcfc923b38e6837095 (diff)
downloadbcm5719-llvm-bf8694d36d8e7f5a5b459a0fb134e4f84daa6376.tar.gz
bcm5719-llvm-bf8694d36d8e7f5a5b459a0fb134e4f84daa6376.zip
R600: Implement ComputeNumSignBitsForTargetNode for BFE
llvm-svn: 209460
Diffstat (limited to 'llvm/lib/Target')
-rw-r--r--llvm/lib/Target/R600/AMDGPUISelLowering.cpp25
-rw-r--r--llvm/lib/Target/R600/AMDGPUISelLowering.h5
2 files changed, 30 insertions, 0 deletions
diff --git a/llvm/lib/Target/R600/AMDGPUISelLowering.cpp b/llvm/lib/Target/R600/AMDGPUISelLowering.cpp
index 870b39eca75..78e79bc98a6 100644
--- a/llvm/lib/Target/R600/AMDGPUISelLowering.cpp
+++ b/llvm/lib/Target/R600/AMDGPUISelLowering.cpp
@@ -1539,3 +1539,28 @@ void AMDGPUTargetLowering::computeKnownBitsForTargetNode(
}
}
}
+
+unsigned AMDGPUTargetLowering::ComputeNumSignBitsForTargetNode(
+ SDValue Op,
+ const SelectionDAG &DAG,
+ unsigned Depth) const {
+ switch (Op.getOpcode()) {
+ case AMDGPUISD::BFE_I32: {
+ ConstantSDNode *Width = dyn_cast<ConstantSDNode>(Op.getOperand(2));
+ if (!Width)
+ return 1;
+
+ unsigned SignBits = 32 - Width->getZExtValue() + 1;
+ ConstantSDNode *Offset = dyn_cast<ConstantSDNode>(Op.getOperand(1));
+ if (!Offset || !Offset->isNullValue())
+ return SignBits;
+
+ // TODO: Could probably figure something out with non-0 offsets.
+ unsigned Op0SignBits = DAG.ComputeNumSignBits(Op.getOperand(0), Depth + 1);
+ return std::max(SignBits, Op0SignBits);
+ }
+
+ default:
+ return 1;
+ }
+}
diff --git a/llvm/lib/Target/R600/AMDGPUISelLowering.h b/llvm/lib/Target/R600/AMDGPUISelLowering.h
index b876c521d32..d5d821d9364 100644
--- a/llvm/lib/Target/R600/AMDGPUISelLowering.h
+++ b/llvm/lib/Target/R600/AMDGPUISelLowering.h
@@ -124,6 +124,11 @@ public:
const SelectionDAG &DAG,
unsigned Depth = 0) const override;
+ virtual unsigned ComputeNumSignBitsForTargetNode(
+ SDValue Op,
+ const SelectionDAG &DAG,
+ unsigned Depth = 0) const override;
+
// Functions defined in AMDILISelLowering.cpp
public:
bool getTgtMemIntrinsic(IntrinsicInfo &Info,
OpenPOWER on IntegriCloud