llvm.org GIT mirror llvm / 145d28e
Fix undefined behavior (left shift of negative value) in Hexagon backend. This bug is reported by UBSan. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216125 91177308-0d34-0410-b5e6-96231b3b80d8 Alexey Samsonov 5 years ago
2 changed file(s) with 6 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
17651765 & HexagonII::ExtentBitsMask;
17661766
17671767 if (isSigned) // if value is signed
1768 return -1 << (bits - 1);
1768 return -1U << (bits - 1);
17691769 else
17701770 return 0;
17711771 }
17791779 & HexagonII::ExtentBitsMask;
17801780
17811781 if (isSigned) // if value is signed
1782 return ~(-1 << (bits - 1));
1782 return ~(-1U << (bits - 1));
17831783 else
1784 return ~(-1 << bits);
1784 return ~(-1U << bits);
17851785 }
17861786
17871787 // Returns true if an instruction can be converted into a non-extended
154154 & HexagonII::ExtentBitsMask;
155155
156156 if (isSigned) // if value is signed
157 return -1 << (bits - 1);
157 return -1U << (bits - 1);
158158 else
159159 return 0;
160160 }
169169 & HexagonII::ExtentBitsMask;
170170
171171 if (isSigned) // if value is signed
172 return ~(-1 << (bits - 1));
172 return ~(-1U << (bits - 1));
173173 else
174 return ~(-1 << bits);
174 return ~(-1U << bits);
175175 }