diff options
| author | Matt Arsenault <Matthew.Arsenault@amd.com> | 2014-09-18 15:52:26 +0000 |
|---|---|---|
| committer | Matt Arsenault <Matthew.Arsenault@amd.com> | 2014-09-18 15:52:26 +0000 |
| commit | 6462f948847dc54ad498cb899fc8ec216a810bbd (patch) | |
| tree | 399dff198331570c1e43c9ed86d4bc340ab6c44c /llvm/lib | |
| parent | 1aa0af2aca19950bf04e2bcfee5d1acbe57310a6 (diff) | |
| download | bcm5719-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.cpp | 13 |
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); } |

