[llvm] r277268 - [Hexagon] Perform bit arithmetic on unsigned to avoid accidentally shifting negative values.

Benjamin Kramer via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 30 06:25:37 PDT 2016


Author: d0k
Date: Sat Jul 30 08:25:37 2016
New Revision: 277268

URL: http://llvm.org/viewvc/llvm-project?rev=277268&view=rev
Log:
[Hexagon] Perform bit arithmetic on unsigned to avoid accidentally shifting negative values.

Found by ubsan.

Modified:
    llvm/trunk/lib/Target/Hexagon/HexagonConstPropagation.cpp

Modified: llvm/trunk/lib/Target/Hexagon/HexagonConstPropagation.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonConstPropagation.cpp?rev=277268&r1=277267&r2=277268&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/HexagonConstPropagation.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/HexagonConstPropagation.cpp Sat Jul 30 08:25:37 2016
@@ -2047,8 +2047,8 @@ bool HexagonConstEvaluator::evaluate(con
     case Hexagon::A2_combineii:  // combine(#s8Ext, #s8)
     case Hexagon::A4_combineii:  // combine(#s8, #u6Ext)
     {
-      int64_t Hi = MI.getOperand(1).getImm();
-      int64_t Lo = MI.getOperand(2).getImm();
+      uint64_t Hi = MI.getOperand(1).getImm();
+      uint64_t Lo = MI.getOperand(2).getImm();
       uint64_t Res = (Hi << 32) | (Lo & 0xFFFFFFFF);
       IntegerType *Ty = Type::getInt64Ty(CX);
       const ConstantInt *CI = ConstantInt::get(Ty, Res, false);




More information about the llvm-commits mailing list