summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2014-09-18 15:52:26 +0000
committerMatt Arsenault <Matthew.Arsenault@amd.com>2014-09-18 15:52:26 +0000
commit6462f948847dc54ad498cb899fc8ec216a810bbd (patch)
tree399dff198331570c1e43c9ed86d4bc340ab6c44c /llvm/lib
parent1aa0af2aca19950bf04e2bcfee5d1acbe57310a6 (diff)
downloadbcm5719-llvm-6462f948847dc54ad498cb899fc8ec216a810bbd.tar.gz
bcm5719-llvm-6462f948847dc54ad498cb899fc8ec216a810bbd.zip
R600: Bug 20982 - Avoid undefined left shift of negative value
I'm not sure what the hardware actually does, so don't bother trying to fold it for now. llvm-svn: 218057
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/R600/AMDGPUISelLowering.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/llvm/lib/Target/R600/AMDGPUISelLowering.cpp b/llvm/lib/Target/R600/AMDGPUISelLowering.cpp
index 8440c39c18d..89dab098710 100644
--- a/llvm/lib/Target/R600/AMDGPUISelLowering.cpp
+++ b/llvm/lib/Target/R600/AMDGPUISelLowering.cpp
@@ -2048,16 +2048,23 @@ SDValue AMDGPUTargetLowering::PerformDAGCombine(SDNode *N,
return DAG.getZeroExtendInReg(BitsFrom, DL, SmallVT);
}
- if (ConstantSDNode *Val = dyn_cast<ConstantSDNode>(N->getOperand(0))) {
+ if (ConstantSDNode *CVal = dyn_cast<ConstantSDNode>(N->getOperand(0))) {
if (Signed) {
+ // Avoid undefined left shift of a negative in the constant fold.
+ // TODO: I'm not sure what the behavior of the hardware is, this should
+ // probably follow that instead.
+ int32_t Val = CVal->getSExtValue();
+ if (Val < 0)
+ return SDValue();
+
return constantFoldBFE<int32_t>(DAG,
- Val->getSExtValue(),
+ Val,
OffsetVal,
WidthVal);
}
return constantFoldBFE<uint32_t>(DAG,
- Val->getZExtValue(),
+ CVal->getZExtValue(),
OffsetVal,
WidthVal);
}
OpenPOWER on IntegriCloud