summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2015-06-23 15:38:24 +0000
committerJustin Bogner <mail@justinbogner.com>2015-06-23 15:38:24 +0000
commita6d383677d710b7258029d6dd775d3dbc73cacc8 (patch)
tree5ac109fd8a2f523d2ab7b68435c6f14d40c01db8 /llvm
parent49381bee2e466d6d43025fb79db2b663dd4f6ae1 (diff)
downloadbcm5719-llvm-a6d383677d710b7258029d6dd775d3dbc73cacc8.tar.gz
bcm5719-llvm-a6d383677d710b7258029d6dd775d3dbc73cacc8.zip
SystemZ: Avoid left shifting negative values (it's UB)
Found by ubsan. llvm-svn: 240420
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/Target/SystemZ/SystemZISelLowering.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
index 91e12c2d9d7..372f6fb3ea5 100644
--- a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
@@ -2005,17 +2005,17 @@ static Comparison getIntrinsicCmp(SelectionDAG &DAG, unsigned Opcode,
else if (Cond == ISD::SETLT || Cond == ISD::SETULT)
// bits above bit 3 for CC==0 (always false), bits above bit 0 for CC==3,
// always true for CC>3.
- C.CCMask = CC < 4 ? -1 << (4 - CC) : -1;
+ C.CCMask = CC < 4 ? ~0U << (4 - CC) : -1;
else if (Cond == ISD::SETGE || Cond == ISD::SETUGE)
// ...and the inverse of that.
- C.CCMask = CC < 4 ? ~(-1 << (4 - CC)) : 0;
+ C.CCMask = CC < 4 ? ~(~0U << (4 - CC)) : 0;
else if (Cond == ISD::SETLE || Cond == ISD::SETULE)
// bit 3 and above for CC==0, bit 0 and above for CC==3 (always true),
// always true for CC>3.
- C.CCMask = CC < 4 ? -1 << (3 - CC) : -1;
+ C.CCMask = CC < 4 ? ~0U << (3 - CC) : -1;
else if (Cond == ISD::SETGT || Cond == ISD::SETUGT)
// ...and the inverse of that.
- C.CCMask = CC < 4 ? ~(-1 << (3 - CC)) : 0;
+ C.CCMask = CC < 4 ? ~(~0U << (3 - CC)) : 0;
else
llvm_unreachable("Unexpected integer comparison type");
C.CCMask &= CCValid;
OpenPOWER on IntegriCloud