Hexagon: Avoid left shifting negative values (it's UB)
authorJustin Bogner <mail@justinbogner.com>
Wed, 24 Jun 2015 06:00:53 +0000 (06:00 +0000)
committerJustin Bogner <mail@justinbogner.com>
Wed, 24 Jun 2015 06:00:53 +0000 (06:00 +0000)
Found by ubsan.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240521 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/Hexagon/MCTargetDesc/HexagonShuffler.h

index 9218fd3eb07056d6a476bfbffbbed6fc39c89430..949ad8cebdcd7be4f665df151b79ad74f771246f 100644 (file)
@@ -34,7 +34,7 @@ public:
   HexagonResource(unsigned s) { setUnits(s); };
 
   void setUnits(unsigned s) {
-    Slots = s & ~(-1 << HEXAGON_PACKET_SIZE);
+    Slots = s & ~(~0U << HEXAGON_PACKET_SIZE);
     setWeight(s);
   };
   unsigned setWeight(unsigned s);