Skip to content

Commit 17cec6a

Browse files
committed
Revert 1c021c6 "[SCEV] Model ptrtoint(SCEVUnknown) cast not as unknown, but as zext/trunc/self of SCEVUnknown"
> While we indeed can't treat them as no-ops, i believe we can/should > do better than just modelling them as `unknown`. `inttoptr` story > is complicated, but for `ptrtoint`, it seems straight-forward > to model it just as a zext-or-trunc of unknown. > > This may be important now that we track towards > making inttoptr/ptrtoint casts not no-op, > and towards preventing folding them into loads/etc > (see D88979/D88789/D88788) > > Reviewed By: mkazantsev > > Differential Revision: https://reviews.llvm.org/D88806 It caused the following assert during Chromium builds: llvm/lib/IR/Constants.cpp:1868: static llvm::Constant *llvm::ConstantExpr::getTrunc(llvm::Constant *, llvm::Type *, bool): Assertion `C->getType()->isIntOrIntVectorTy() && "Trunc operand must be integer"' failed. See code review for a link to a reproducer. This reverts commit 1c021c6.
1 parent 7341123 commit 17cec6a

File tree

9 files changed

+53
-87
lines changed

9 files changed

+53
-87
lines changed

llvm/lib/Analysis/ScalarEvolution.cpp

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3505,15 +3505,15 @@ const SCEV *ScalarEvolution::getUMinExpr(SmallVectorImpl<const SCEV *> &Ops) {
35053505
}
35063506

35073507
const SCEV *ScalarEvolution::getSizeOfExpr(Type *IntTy, Type *AllocTy) {
3508+
// We can bypass creating a target-independent
3509+
// constant expression and then folding it back into a ConstantInt.
3510+
// This is just a compile-time optimization.
35083511
if (isa<ScalableVectorType>(AllocTy)) {
35093512
Constant *NullPtr = Constant::getNullValue(AllocTy->getPointerTo());
35103513
Constant *One = ConstantInt::get(IntTy, 1);
35113514
Constant *GEP = ConstantExpr::getGetElementPtr(AllocTy, NullPtr, One);
3512-
return getUnknown(ConstantExpr::getPtrToInt(GEP, IntTy));
3515+
return getSCEV(ConstantExpr::getPtrToInt(GEP, IntTy));
35133516
}
3514-
// We can bypass creating a target-independent
3515-
// constant expression and then folding it back into a ConstantInt.
3516-
// This is just a compile-time optimization.
35173517
return getConstant(IntTy, getDataLayout().getTypeAllocSize(AllocTy));
35183518
}
35193519

@@ -6301,36 +6301,6 @@ const SCEV *ScalarEvolution::createSCEV(Value *V) {
63016301
return getSCEV(U->getOperand(0));
63026302
break;
63036303

6304-
case Instruction::PtrToInt: {
6305-
// It's tempting to handle inttoptr and ptrtoint as no-ops,
6306-
// however this can lead to pointer expressions which cannot safely be
6307-
// expanded to GEPs because ScalarEvolution doesn't respect
6308-
// the GEP aliasing rules when simplifying integer expressions.
6309-
//
6310-
// However, given
6311-
// %x = ???
6312-
// %y = ptrtoint %x
6313-
// %z = ptrtoint %x
6314-
// it is safe to say that %y and %z are the same thing.
6315-
//
6316-
// So instead of modelling the cast itself as unknown,
6317-
// since the casts are transparent within SCEV,
6318-
// we can at least model the casts original value as unknow instead.
6319-
6320-
// BUT, there's caveat. If we simply model %x as unknown, unrelated uses
6321-
// of %x will also see it as unknown, which is obviously bad.
6322-
// So we can only do this iff %x would be modelled as unknown anyways.
6323-
auto *OpSCEV = getSCEV(U->getOperand(0));
6324-
if (isa<SCEVUnknown>(OpSCEV))
6325-
return getTruncateOrZeroExtend(OpSCEV, U->getType());
6326-
// If we can model the operand, however, we must fallback to modelling
6327-
// the whole cast as unknown instead.
6328-
LLVM_FALLTHROUGH;
6329-
}
6330-
case Instruction::IntToPtr:
6331-
// We can't do this for inttoptr at all, however.
6332-
return getUnknown(V);
6333-
63346304
case Instruction::SDiv:
63356305
// If both operands are non-negative, this is just an udiv.
63366306
if (isKnownNonNegative(getSCEV(U->getOperand(0))) &&
@@ -6345,6 +6315,11 @@ const SCEV *ScalarEvolution::createSCEV(Value *V) {
63456315
return getURemExpr(getSCEV(U->getOperand(0)), getSCEV(U->getOperand(1)));
63466316
break;
63476317

6318+
// It's tempting to handle inttoptr and ptrtoint as no-ops, however this can
6319+
// lead to pointer expressions which cannot safely be expanded to GEPs,
6320+
// because ScalarEvolution doesn't respect the GEP aliasing rules when
6321+
// simplifying integer expressions.
6322+
63486323
case Instruction::GetElementPtr:
63496324
return createNodeForGEP(cast<GEPOperator>(U));
63506325

llvm/lib/Transforms/Utils/SimplifyIndVar.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ static bool willNotOverflow(ScalarEvolution *SE, Instruction::BinaryOps BinOp,
427427
: &ScalarEvolution::getZeroExtendExpr;
428428

429429
// Check ext(LHS op RHS) == ext(LHS) op ext(RHS)
430-
auto *NarrowTy = cast<IntegerType>(SE->getEffectiveSCEVType(LHS->getType()));
430+
auto *NarrowTy = cast<IntegerType>(LHS->getType());
431431
auto *WideTy =
432432
IntegerType::get(NarrowTy->getContext(), NarrowTy->getBitWidth() * 2);
433433

llvm/test/Analysis/ScalarEvolution/add-expr-pointer-operand-sorting.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ define i32 @d(i32 %base) {
3333
; CHECK-NEXT: %1 = load i32*, i32** @c, align 8
3434
; CHECK-NEXT: --> %1 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %for.cond: Variant }
3535
; CHECK-NEXT: %sub.ptr.lhs.cast = ptrtoint i32* %1 to i64
36-
; CHECK-NEXT: --> %1 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %for.cond: Variant }
36+
; CHECK-NEXT: --> %sub.ptr.lhs.cast U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %for.cond: Variant }
3737
; CHECK-NEXT: %sub.ptr.sub = sub i64 %sub.ptr.lhs.cast, ptrtoint ([1 x i32]* @b to i64)
38-
; CHECK-NEXT: --> ((-1 * @b) + %1) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %for.cond: Variant }
38+
; CHECK-NEXT: --> ((-1 * ptrtoint ([1 x i32]* @b to i64)) + %sub.ptr.lhs.cast) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %for.cond: Variant }
3939
; CHECK-NEXT: %sub.ptr.div = sdiv exact i64 %sub.ptr.sub, 4
4040
; CHECK-NEXT: --> %sub.ptr.div U: full-set S: [-2305843009213693952,2305843009213693952) Exits: <<Unknown>> LoopDispositions: { %for.cond: Variant }
4141
; CHECK-NEXT: %arrayidx1 = getelementptr inbounds [1 x i8], [1 x i8]* %arrayidx, i64 0, i64 %sub.ptr.div

llvm/test/Analysis/ScalarEvolution/no-wrap-add-exprs.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,14 +170,14 @@ define void @f3(i8* %x_addr, i8* %y_addr, i32* %tmp_addr) {
170170
%int5 = add i32 %int0, 5
171171
%int.zext = zext i32 %int5 to i64
172172
; CHECK: %int.zext = zext i32 %int5 to i64
173-
; CHECK-NEXT: --> (1 + (zext i32 (4 + (trunc [16 x i8]* @z_addr to i32)) to i64))<nuw><nsw> U: [1,4294967294) S: [1,4294967297)
173+
; CHECK-NEXT: --> (1 + (zext i32 (4 + %int0) to i64))<nuw><nsw> U: [1,4294967294) S: [1,4294967297)
174174

175175
%ptr_noalign = bitcast [16 x i8]* @z_addr_noalign to i8*
176176
%int0_na = ptrtoint i8* %ptr_noalign to i32
177177
%int5_na = add i32 %int0_na, 5
178178
%int.zext_na = zext i32 %int5_na to i64
179179
; CHECK: %int.zext_na = zext i32 %int5_na to i64
180-
; CHECK-NEXT: --> (zext i32 (5 + (trunc [16 x i8]* @z_addr_noalign to i32)) to i64) U: [0,4294967296) S: [0,4294967296)
180+
; CHECK-NEXT: --> (zext i32 (5 + %int0_na) to i64) U: [0,4294967296) S: [0,4294967296)
181181

182182
%tmp = load i32, i32* %tmp_addr
183183
%mul = and i32 %tmp, -4

llvm/test/Analysis/ScalarEvolution/ptrtoint.ll

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,25 @@ define void @ptrtoint(i8* %in, i64* %out0, i32* %out1, i16* %out2, i128* %out3)
1616
; X64-LABEL: 'ptrtoint'
1717
; X64-NEXT: Classifying expressions for: @ptrtoint
1818
; X64-NEXT: %p0 = ptrtoint i8* %in to i64
19-
; X64-NEXT: --> %in U: full-set S: full-set
19+
; X64-NEXT: --> %p0 U: full-set S: full-set
2020
; X64-NEXT: %p1 = ptrtoint i8* %in to i32
21-
; X64-NEXT: --> (trunc i8* %in to i32) U: full-set S: full-set
21+
; X64-NEXT: --> %p1 U: full-set S: full-set
2222
; X64-NEXT: %p2 = ptrtoint i8* %in to i16
23-
; X64-NEXT: --> (trunc i8* %in to i16) U: full-set S: full-set
23+
; X64-NEXT: --> %p2 U: full-set S: full-set
2424
; X64-NEXT: %p3 = ptrtoint i8* %in to i128
25-
; X64-NEXT: --> (zext i8* %in to i128) U: [0,18446744073709551616) S: [0,18446744073709551616)
25+
; X64-NEXT: --> %p3 U: [0,18446744073709551616) S: [-18446744073709551616,18446744073709551616)
2626
; X64-NEXT: Determining loop execution counts for: @ptrtoint
2727
;
2828
; X32-LABEL: 'ptrtoint'
2929
; X32-NEXT: Classifying expressions for: @ptrtoint
3030
; X32-NEXT: %p0 = ptrtoint i8* %in to i64
31-
; X32-NEXT: --> (zext i8* %in to i64) U: [0,4294967296) S: [0,4294967296)
31+
; X32-NEXT: --> %p0 U: [0,4294967296) S: [-4294967296,4294967296)
3232
; X32-NEXT: %p1 = ptrtoint i8* %in to i32
33-
; X32-NEXT: --> %in U: full-set S: full-set
33+
; X32-NEXT: --> %p1 U: full-set S: full-set
3434
; X32-NEXT: %p2 = ptrtoint i8* %in to i16
35-
; X32-NEXT: --> (trunc i8* %in to i16) U: full-set S: full-set
35+
; X32-NEXT: --> %p2 U: full-set S: full-set
3636
; X32-NEXT: %p3 = ptrtoint i8* %in to i128
37-
; X32-NEXT: --> (zext i8* %in to i128) U: [0,4294967296) S: [0,4294967296)
37+
; X32-NEXT: --> %p3 U: [0,4294967296) S: [-4294967296,4294967296)
3838
; X32-NEXT: Determining loop execution counts for: @ptrtoint
3939
;
4040
%p0 = ptrtoint i8* %in to i64
@@ -53,25 +53,25 @@ define void @ptrtoint_as1(i8 addrspace(1)* %in, i64* %out0, i32* %out1, i16* %ou
5353
; X64-LABEL: 'ptrtoint_as1'
5454
; X64-NEXT: Classifying expressions for: @ptrtoint_as1
5555
; X64-NEXT: %p0 = ptrtoint i8 addrspace(1)* %in to i64
56-
; X64-NEXT: --> %in U: full-set S: full-set
56+
; X64-NEXT: --> %p0 U: full-set S: full-set
5757
; X64-NEXT: %p1 = ptrtoint i8 addrspace(1)* %in to i32
58-
; X64-NEXT: --> (trunc i8 addrspace(1)* %in to i32) U: full-set S: full-set
58+
; X64-NEXT: --> %p1 U: full-set S: full-set
5959
; X64-NEXT: %p2 = ptrtoint i8 addrspace(1)* %in to i16
60-
; X64-NEXT: --> (trunc i8 addrspace(1)* %in to i16) U: full-set S: full-set
60+
; X64-NEXT: --> %p2 U: full-set S: full-set
6161
; X64-NEXT: %p3 = ptrtoint i8 addrspace(1)* %in to i128
62-
; X64-NEXT: --> (zext i8 addrspace(1)* %in to i128) U: [0,18446744073709551616) S: [0,18446744073709551616)
62+
; X64-NEXT: --> %p3 U: [0,18446744073709551616) S: [-18446744073709551616,18446744073709551616)
6363
; X64-NEXT: Determining loop execution counts for: @ptrtoint_as1
6464
;
6565
; X32-LABEL: 'ptrtoint_as1'
6666
; X32-NEXT: Classifying expressions for: @ptrtoint_as1
6767
; X32-NEXT: %p0 = ptrtoint i8 addrspace(1)* %in to i64
68-
; X32-NEXT: --> (zext i8 addrspace(1)* %in to i64) U: [0,4294967296) S: [0,4294967296)
68+
; X32-NEXT: --> %p0 U: [0,4294967296) S: [-4294967296,4294967296)
6969
; X32-NEXT: %p1 = ptrtoint i8 addrspace(1)* %in to i32
70-
; X32-NEXT: --> %in U: full-set S: full-set
70+
; X32-NEXT: --> %p1 U: full-set S: full-set
7171
; X32-NEXT: %p2 = ptrtoint i8 addrspace(1)* %in to i16
72-
; X32-NEXT: --> (trunc i8 addrspace(1)* %in to i16) U: full-set S: full-set
72+
; X32-NEXT: --> %p2 U: full-set S: full-set
7373
; X32-NEXT: %p3 = ptrtoint i8 addrspace(1)* %in to i128
74-
; X32-NEXT: --> (zext i8 addrspace(1)* %in to i128) U: [0,4294967296) S: [0,4294967296)
74+
; X32-NEXT: --> %p3 U: [0,4294967296) S: [-4294967296,4294967296)
7575
; X32-NEXT: Determining loop execution counts for: @ptrtoint_as1
7676
;
7777
%p0 = ptrtoint i8 addrspace(1)* %in to i64
@@ -92,15 +92,15 @@ define void @ptrtoint_of_bitcast(i8* %in, i64* %out0) {
9292
; X64-NEXT: %in_casted = bitcast i8* %in to float*
9393
; X64-NEXT: --> %in U: full-set S: full-set
9494
; X64-NEXT: %p0 = ptrtoint float* %in_casted to i64
95-
; X64-NEXT: --> %in U: full-set S: full-set
95+
; X64-NEXT: --> %p0 U: full-set S: full-set
9696
; X64-NEXT: Determining loop execution counts for: @ptrtoint_of_bitcast
9797
;
9898
; X32-LABEL: 'ptrtoint_of_bitcast'
9999
; X32-NEXT: Classifying expressions for: @ptrtoint_of_bitcast
100100
; X32-NEXT: %in_casted = bitcast i8* %in to float*
101101
; X32-NEXT: --> %in U: full-set S: full-set
102102
; X32-NEXT: %p0 = ptrtoint float* %in_casted to i64
103-
; X32-NEXT: --> (zext i8* %in to i64) U: [0,4294967296) S: [0,4294967296)
103+
; X32-NEXT: --> %p0 U: [0,4294967296) S: [-4294967296,4294967296)
104104
; X32-NEXT: Determining loop execution counts for: @ptrtoint_of_bitcast
105105
;
106106
%in_casted = bitcast i8* %in to float*
@@ -116,15 +116,15 @@ define void @ptrtoint_of_addrspacecast(i8* %in, i64* %out0) {
116116
; X64-NEXT: %in_casted = addrspacecast i8* %in to i8 addrspace(1)*
117117
; X64-NEXT: --> %in_casted U: full-set S: full-set
118118
; X64-NEXT: %p0 = ptrtoint i8 addrspace(1)* %in_casted to i64
119-
; X64-NEXT: --> %in_casted U: full-set S: full-set
119+
; X64-NEXT: --> %p0 U: full-set S: full-set
120120
; X64-NEXT: Determining loop execution counts for: @ptrtoint_of_addrspacecast
121121
;
122122
; X32-LABEL: 'ptrtoint_of_addrspacecast'
123123
; X32-NEXT: Classifying expressions for: @ptrtoint_of_addrspacecast
124124
; X32-NEXT: %in_casted = addrspacecast i8* %in to i8 addrspace(1)*
125125
; X32-NEXT: --> %in_casted U: full-set S: full-set
126126
; X32-NEXT: %p0 = ptrtoint i8 addrspace(1)* %in_casted to i64
127-
; X32-NEXT: --> (zext i8 addrspace(1)* %in_casted to i64) U: [0,4294967296) S: [0,4294967296)
127+
; X32-NEXT: --> %p0 U: [0,4294967296) S: [-4294967296,4294967296)
128128
; X32-NEXT: Determining loop execution counts for: @ptrtoint_of_addrspacecast
129129
;
130130
%in_casted = addrspacecast i8* %in to i8 addrspace(1)*
@@ -140,15 +140,15 @@ define void @ptrtoint_of_inttoptr(i64 %in, i64* %out0) {
140140
; X64-NEXT: %in_casted = inttoptr i64 %in to i8*
141141
; X64-NEXT: --> %in_casted U: full-set S: full-set
142142
; X64-NEXT: %p0 = ptrtoint i8* %in_casted to i64
143-
; X64-NEXT: --> %in_casted U: full-set S: full-set
143+
; X64-NEXT: --> %p0 U: full-set S: full-set
144144
; X64-NEXT: Determining loop execution counts for: @ptrtoint_of_inttoptr
145145
;
146146
; X32-LABEL: 'ptrtoint_of_inttoptr'
147147
; X32-NEXT: Classifying expressions for: @ptrtoint_of_inttoptr
148148
; X32-NEXT: %in_casted = inttoptr i64 %in to i8*
149149
; X32-NEXT: --> %in_casted U: full-set S: full-set
150150
; X32-NEXT: %p0 = ptrtoint i8* %in_casted to i64
151-
; X32-NEXT: --> (zext i8* %in_casted to i64) U: [0,4294967296) S: [0,4294967296)
151+
; X32-NEXT: --> %p0 U: [0,4294967296) S: [-4294967296,4294967296)
152152
; X32-NEXT: Determining loop execution counts for: @ptrtoint_of_inttoptr
153153
;
154154
%in_casted = inttoptr i64 %in to i8*
@@ -197,17 +197,11 @@ define void @ptrtoint_of_nullptr(i64* %out0) {
197197

198198
; A constant inttoptr argument of an ptrtoint is still bad.
199199
define void @ptrtoint_of_constantexpr_inttoptr(i64* %out0) {
200-
; X64-LABEL: 'ptrtoint_of_constantexpr_inttoptr'
201-
; X64-NEXT: Classifying expressions for: @ptrtoint_of_constantexpr_inttoptr
202-
; X64-NEXT: %p0 = ptrtoint i8* inttoptr (i64 42 to i8*) to i64
203-
; X64-NEXT: --> inttoptr (i64 42 to i8*) U: [42,43) S: [-64,64)
204-
; X64-NEXT: Determining loop execution counts for: @ptrtoint_of_constantexpr_inttoptr
205-
;
206-
; X32-LABEL: 'ptrtoint_of_constantexpr_inttoptr'
207-
; X32-NEXT: Classifying expressions for: @ptrtoint_of_constantexpr_inttoptr
208-
; X32-NEXT: %p0 = ptrtoint i8* inttoptr (i64 42 to i8*) to i64
209-
; X32-NEXT: --> (zext i8* inttoptr (i64 42 to i8*) to i64) U: [42,43) S: [0,4294967296)
210-
; X32-NEXT: Determining loop execution counts for: @ptrtoint_of_constantexpr_inttoptr
200+
; ALL-LABEL: 'ptrtoint_of_constantexpr_inttoptr'
201+
; ALL-NEXT: Classifying expressions for: @ptrtoint_of_constantexpr_inttoptr
202+
; ALL-NEXT: %p0 = ptrtoint i8* inttoptr (i64 42 to i8*) to i64
203+
; ALL-NEXT: --> %p0 U: [42,43) S: [-64,64)
204+
; ALL-NEXT: Determining loop execution counts for: @ptrtoint_of_constantexpr_inttoptr
211205
;
212206
%p0 = ptrtoint i8* inttoptr (i64 42 to i8*) to i64
213207
store i64 %p0, i64* %out0

llvm/test/CodeGen/ARM/lsr-undef-in-binop.ll

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,7 @@ define linkonce_odr i32 @vector_insert(%"class.std::__1::vector.182"*, [1 x i32]
186186
br i1 %114, label %124, label %115
187187

188188
; CHECK-LABEL: .preheader:
189-
; CHECK-NEXT: [[NEG_NEW:%[0-9]+]] = sub i32 0, [[NEW_CAST]]
190-
; CHECK-NEXT: getelementptr i8, i8* %97, i32 [[NEG_NEW]]
191-
189+
; CHECK-NEXT: sub i32 [[OLD_CAST]], [[NEW_CAST]]
192190
; <label>:115: ; preds = %111, %115
193191
%116 = phi i8* [ %118, %115 ], [ %97, %111 ]
194192
%117 = phi i8* [ %119, %115 ], [ %11, %111 ]

llvm/test/CodeGen/X86/ragreedy-hoist-spill.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,9 @@ define i8* @SyFgets(i8* %line, i64 %length, i64 %fid) {
268268
; CHECK-NEXT: LBB0_48: ## %if.then1477
269269
; CHECK-NEXT: movl $1, %edx
270270
; CHECK-NEXT: callq _write
271+
; CHECK-NEXT: subq %rbx, %r14
271272
; CHECK-NEXT: movq _syHistory@{{.*}}(%rip), %rax
272-
; CHECK-NEXT: subq %rbx, %rax
273-
; CHECK-NEXT: leaq 8189(%rax,%r14), %rax
273+
; CHECK-NEXT: leaq 8189(%r14,%rax), %rax
274274
; CHECK-NEXT: .p2align 4, 0x90
275275
; CHECK-NEXT: LBB0_49: ## %for.body1723
276276
; CHECK-NEXT: ## =>This Inner Loop Header: Depth=1

llvm/test/Transforms/IndVarSimplify/2011-11-01-lftrptr.ll

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -166,23 +166,21 @@ define i8 @testnullptrint(i8* %buf, i8* %end) nounwind {
166166
; PTR64-NEXT: ret i8 [[RET]]
167167
;
168168
; PTR32-LABEL: @testnullptrint(
169-
; PTR32-NEXT: [[BUF1:%.*]] = ptrtoint i8* [[BUF:%.*]] to i32
170169
; PTR32-NEXT: br label [[LOOPGUARD:%.*]]
171170
; PTR32: loopguard:
172-
; PTR32-NEXT: [[BI:%.*]] = ptrtoint i8* [[BUF]] to i32
171+
; PTR32-NEXT: [[BI:%.*]] = ptrtoint i8* [[BUF:%.*]] to i32
173172
; PTR32-NEXT: [[EI:%.*]] = ptrtoint i8* [[END:%.*]] to i32
174173
; PTR32-NEXT: [[CNT:%.*]] = sub i32 [[EI]], [[BI]]
174+
; PTR32-NEXT: [[CNT1:%.*]] = inttoptr i32 [[CNT]] to i8*
175175
; PTR32-NEXT: [[GUARD:%.*]] = icmp ult i32 0, [[CNT]]
176176
; PTR32-NEXT: br i1 [[GUARD]], label [[PREHEADER:%.*]], label [[EXIT:%.*]]
177177
; PTR32: preheader:
178-
; PTR32-NEXT: [[TMP1:%.*]] = sub i32 0, [[BUF1]]
179-
; PTR32-NEXT: [[SCEVGEP:%.*]] = getelementptr i8, i8* [[END]], i32 [[TMP1]]
180178
; PTR32-NEXT: br label [[LOOP:%.*]]
181179
; PTR32: loop:
182180
; PTR32-NEXT: [[P_01_US_US:%.*]] = phi i8* [ null, [[PREHEADER]] ], [ [[GEP:%.*]], [[LOOP]] ]
183181
; PTR32-NEXT: [[GEP]] = getelementptr inbounds i8, i8* [[P_01_US_US]], i64 1
184-
; PTR32-NEXT: [[SNEXT:%.*]] = load i8, i8* [[GEP]], align 1
185-
; PTR32-NEXT: [[EXITCOND:%.*]] = icmp ne i8* [[GEP]], [[SCEVGEP]]
182+
; PTR32-NEXT: [[SNEXT:%.*]] = load i8, i8* [[GEP]]
183+
; PTR32-NEXT: [[EXITCOND:%.*]] = icmp ne i8* [[GEP]], [[CNT1]]
186184
; PTR32-NEXT: br i1 [[EXITCOND]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]]
187185
; PTR32: exit.loopexit:
188186
; PTR32-NEXT: [[SNEXT_LCSSA:%.*]] = phi i8 [ [[SNEXT]], [[LOOP]] ]
@@ -258,10 +256,10 @@ define i8 @testptrint(i8* %buf, i8* %end) nounwind {
258256
; PTR32-NEXT: [[P_01_US_US:%.*]] = phi i8* [ [[BUF]], [[PREHEADER]] ], [ [[GEP:%.*]], [[LOOP]] ]
259257
; PTR32-NEXT: [[IV:%.*]] = phi i32 [ [[BI]], [[PREHEADER]] ], [ [[IVNEXT:%.*]], [[LOOP]] ]
260258
; PTR32-NEXT: [[GEP]] = getelementptr inbounds i8, i8* [[P_01_US_US]], i64 1
261-
; PTR32-NEXT: [[SNEXT:%.*]] = load i8, i8* [[GEP]], align 1
259+
; PTR32-NEXT: [[SNEXT:%.*]] = load i8, i8* [[GEP]]
262260
; PTR32-NEXT: [[IVNEXT]] = add nuw i32 [[IV]], 1
263-
; PTR32-NEXT: [[CMP:%.*]] = icmp ult i32 [[IVNEXT]], [[CNT]]
264-
; PTR32-NEXT: br i1 [[CMP]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]]
261+
; PTR32-NEXT: [[EXITCOND:%.*]] = icmp ne i32 [[IVNEXT]], [[CNT]]
262+
; PTR32-NEXT: br i1 [[EXITCOND]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]]
265263
; PTR32: exit.loopexit:
266264
; PTR32-NEXT: [[SNEXT_LCSSA:%.*]] = phi i8 [ [[SNEXT]], [[LOOP]] ]
267265
; PTR32-NEXT: br label [[EXIT]]

polly/test/Isl/CodeGen/scev_looking_through_bitcasts.ll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@ bitmap_element_allocate.exit:
3232

3333

3434
; CHECK: polly.stmt.cond.end73.i:
35-
; CHECK-NEXT: store %structty* undef, %structty** %b.s2a
35+
; CHECK-NEXT: %0 = bitcast %structty** %b.s2a to i8**
36+
; CHECK-NEXT: store i8* undef, i8** %0
3637
; CHECK-NEXT: br label %polly.exiting

0 commit comments

Comments
 (0)