[PATCH] D88806: [SCEV] Model ptrtoint(SCEVUnknown) cast not as unknown, but as zext/trunc/self of SCEVUnknown
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 8 06:31:59 PDT 2020
lebedev.ri marked an inline comment as done.
lebedev.ri added inline comments.
================
Comment at: llvm/test/Analysis/ScalarEvolution/no-wrap-add-exprs.ll:173
; CHECK: %int.zext = zext i32 %int5 to i64
-; CHECK-NEXT: --> (1 + (zext i32 (4 + %int0) to i64))<nuw><nsw> U: [1,4294967294) S: [1,4294967297)
+; CHECK-NEXT: --> (1 + (zext i32 (4 + (trunc i8* %ptr to i32)) to i64))<nuw><nsw> U: [1,4294967294) S: [1,4294967297)
----------------
mkazantsev wrote:
> I don't quite get how we ended up with this. Do we somehow know that `i8*` is wider than `i32`? Is it coming from default data layout or?..
We called `getTruncateOrZeroExtend(OpSCEV, U->getType())` on `%int0 = ptrtoint i8* %ptr to i32`, which is:
```
const SCEV *ScalarEvolution::getTruncateOrZeroExtend(const SCEV *V, Type *Ty,
unsigned Depth) {
Type *SrcTy = V->getType();
assert(SrcTy->isIntOrPtrTy() && Ty->isIntOrPtrTy() &&
"Cannot truncate or zero extend with non-integer arguments!");
if (getTypeSizeInBits(SrcTy) == getTypeSizeInBits(Ty))
return V; // No conversion
if (getTypeSizeInBits(SrcTy) > getTypeSizeInBits(Ty))
return getTruncateExpr(V, Ty, Depth);
return getZeroExtendExpr(V, Ty, Depth);
}
```
, where
```
/// Return the size in bits of the specified type, for which isSCEVable must
/// return true.
uint64_t ScalarEvolution::getTypeSizeInBits(Type *Ty) const {
assert(isSCEVable(Ty) && "Type is not SCEVable!");
if (Ty->isPointerTy())
return getDataLayout().getIndexTypeSizeInBits(Ty);
return getDataLayout().getTypeSizeInBits(Ty);
}
```
So yes, default datalayout.
Which may mean, we need to hardcode it here in the test.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D88806/new/
https://reviews.llvm.org/D88806
More information about the llvm-commits
mailing list