llvm.org GIT mirror llvm / 4b913c2
[BasicAA] Fix linearization of shifts beyond the bitwidth. Thanks to Simon Pilgrim for the reduced testcase. Fixes PR35821. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@321873 91177308-0d34-0410-b5e6-96231b3b80d8 Davide Italiano 2 years ago
2 changed file(s) with 24 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
284284 case Instruction::Shl:
285285 V = GetLinearExpression(BOp->getOperand(0), Scale, Offset, ZExtBits,
286286 SExtBits, DL, Depth + 1, AC, DT, NSW, NUW);
287
288 // We're trying to linearize an expression of the kind:
289 // shl i8 -128, 36
290 // where the shift count exceeds the bitwidth of the type.
291 // We can't decompose this further (the expression would return
292 // a poison value).
293 if (Offset.getBitWidth() < RHS.getLimitedValue() ||
294 Scale.getBitWidth() < RHS.getLimitedValue()) {
295 Scale = 1;
296 Offset = 0;
297 return V;
298 }
299
287300 Offset <<= RHS.getLimitedValue();
288301 Scale <<= RHS.getLimitedValue();
289302 // the semantics of nsw and nuw for left shifts don't match those of
0 ; RUN: opt %s -aa-eval -disable-output 2>&1 | FileCheck %s
1
2 ; CHECK: 6 Total Alias Queries Performed
3 ; CHECK-NEXT: 6 no alias responses
4
5 define void @patatino() {
6 %G26 = getelementptr i1, i1* undef, i1 undef
7 %B20 = shl i8 -128, 16
8 %G47 = getelementptr i1*, i1** undef, i8 %B20
9 ret void
10 }