Skip to content

Commit b96114c

Browse files
committed
[SCEV] Remove premature assert. PR46786
This assert was added to verify assumption that GEP's SCEV will be of pointer type, basing on fact that it should be a SCEVAddExpr with (at least) last operand being pointer. Two notes: - GEP's SCEV does not have to be a SCEVAddExpr after all simplifications; - In current state, GEP's SCEV does not have to have at least one pointer operands (all of them can become int during the transforms). However, we might want to be at a point where it is true. We are currently removing this assert and will try to enumerate the cases where "is pointer" notion might be lost during the transforms. When all of them are fixed, we can return it. Differential Revision: https://reviews.llvm.org/D84294 Reviewed By: lebedev.ri
1 parent 44967fc commit b96114c

File tree

2 files changed

+38
-4
lines changed

2 files changed

+38
-4
lines changed

llvm/lib/Analysis/ScalarEvolution.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3317,10 +3317,7 @@ ScalarEvolution::getGEPExpr(GEPOperator *GEP,
33173317
}
33183318

33193319
// Add the total offset from all the GEP indices to the base.
3320-
auto *GEPExpr = getAddExpr(BaseExpr, TotalOffset, Wrap);
3321-
assert(BaseExpr->getType() == GEPExpr->getType() &&
3322-
"GEP should not change type mid-flight.");
3323-
return GEPExpr;
3320+
return getAddExpr(BaseExpr, TotalOffset, Wrap);
33243321
}
33253322

33263323
std::tuple<SCEV *, FoldingSetNodeID, void *>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
2+
; RUN: opt < %s -analyze -enable-new-pm=0 -scalar-evolution | FileCheck %s
3+
; RUN: opt < %s -disable-output "-passes=print<scalar-evolution>" 2>&1 | FileCheck %s
4+
5+
source_filename = "input.cpp"
6+
target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
7+
8+
; Function Attrs: nofree
9+
define i8* @FSE_decompress_usingDTable(i8* %arg, i32 %arg1, i32 %arg2, i32 %arg3) local_unnamed_addr #0 {
10+
; CHECK-LABEL: 'FSE_decompress_usingDTable'
11+
; CHECK-NEXT: Classifying expressions for: @FSE_decompress_usingDTable
12+
; CHECK-NEXT: %i = getelementptr inbounds i8, i8* %arg, i32 %arg2
13+
; CHECK-NEXT: --> (%arg2 + %arg)<nsw> U: full-set S: full-set
14+
; CHECK-NEXT: %i4 = sub nsw i32 0, %arg1
15+
; CHECK-NEXT: --> (-1 * %arg1) U: full-set S: full-set
16+
; CHECK-NEXT: %i5 = getelementptr inbounds i8, i8* %i, i32 %i4
17+
; CHECK-NEXT: --> ((-1 * %arg1) + %arg2 + %arg) U: full-set S: full-set
18+
; CHECK-NEXT: %i7 = select i1 %i6, i32 %arg2, i32 %arg1
19+
; CHECK-NEXT: --> ((-1 * %arg) + (((-1 * %arg1) + %arg2 + %arg) umin %arg) + %arg1) U: full-set S: full-set
20+
; CHECK-NEXT: %i8 = sub i32 %arg3, %i7
21+
; CHECK-NEXT: --> ((-1 * (((-1 * %arg1) + %arg2 + %arg) umin %arg)) + (-1 * %arg1) + %arg3 + %arg) U: full-set S: full-set
22+
; CHECK-NEXT: %i9 = getelementptr inbounds i8, i8* %arg, i32 %i8
23+
; CHECK-NEXT: --> ((2 * %arg) + (-1 * (((-1 * %arg1) + %arg2 + %arg) umin %arg)) + (-1 * %arg1) + %arg3) U: full-set S: full-set
24+
; CHECK-NEXT: Determining loop execution counts for: @FSE_decompress_usingDTable
25+
;
26+
bb:
27+
%i = getelementptr inbounds i8, i8* %arg, i32 %arg2
28+
%i4 = sub nsw i32 0, %arg1
29+
%i5 = getelementptr inbounds i8, i8* %i, i32 %i4
30+
%i6 = icmp ult i8* %i5, %arg
31+
%i7 = select i1 %i6, i32 %arg2, i32 %arg1
32+
%i8 = sub i32 %arg3, %i7
33+
%i9 = getelementptr inbounds i8, i8* %arg, i32 %i8
34+
ret i8* %i9
35+
}
36+
37+
attributes #0 = { nofree }

0 commit comments

Comments
 (0)