Use SCEVPtrToAddr instead of SCEVPtrToInt for pointer -> int conversion in SCEV, like when computing trip count expressions. getPtrToIntExpr now also creates SCEVPtrToAddrExpr. Removal of SCEVPtrToIntExpr out of this PR, to limit the scope and will be done as NFC follow-up. PR: https://github.com/llvm/llvm-project/pull/180244
29 lines
1 KiB
LLVM
29 lines
1 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
|
; RUN: opt < %s -passes=indvars -S | FileCheck %s
|
|
|
|
declare void @foo(i64 noundef)
|
|
|
|
; Function Attrs: mustprogress noreturn uwtable
|
|
define void @pr59633(ptr noundef %ptr) {
|
|
; CHECK-LABEL: @pr59633(
|
|
; CHECK-NEXT: entry:
|
|
; CHECK-NEXT: [[PTR1:%.*]] = ptrtoaddr ptr [[PTR:%.*]] to i64
|
|
; CHECK-NEXT: [[TMP0:%.*]] = trunc i64 [[PTR1]] to i4
|
|
; CHECK-NEXT: [[TMP1:%.*]] = zext i4 [[TMP0]] to i64
|
|
; CHECK-NEXT: br label [[WHILE_BODY:%.*]]
|
|
; CHECK: while.body:
|
|
; CHECK-NEXT: tail call void @foo(i64 noundef [[TMP1]])
|
|
; CHECK-NEXT: br label [[WHILE_BODY]]
|
|
;
|
|
entry:
|
|
br label %while.body
|
|
|
|
while.body: ; preds = %entry, %while.body
|
|
%ptr.addr.0 = phi ptr [ %ptr, %entry ], [ %add.ptr, %while.body ]
|
|
%0 = ptrtoint ptr %ptr.addr.0 to i64
|
|
%and = and i64 %0, 15 ; loop invariant
|
|
tail call void @foo(i64 noundef %and)
|
|
%add.ptr = getelementptr inbounds i8, ptr %ptr.addr.0, i64 16
|
|
br label %while.body
|
|
}
|
|
|