forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[LoopUnroll] Consider simplified operands while retrieving TTI instru…
…ction cost (llvm#70929) Get more precise cost of instruction after LoopUnroll considering that some operands of it can be simplified, e.g. induction variable will be replaced by constant after full unrolling.
- Loading branch information
1 parent
f89fe08
commit ffd79b3
Showing
3 changed files
with
59 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2 | ||
; RUN: opt < %s -S -mtriple=riscv64 -passes=loop-unroll | FileCheck %s | ||
|
||
; Function Attrs: optsize | ||
define void @foo(ptr %array, i32 %x) #0 { | ||
; CHECK-LABEL: define void @foo | ||
; CHECK-SAME: (ptr [[ARRAY:%.*]], i32 [[X:%.*]]) #[[ATTR0:[0-9]+]] { | ||
; CHECK-NEXT: entry: | ||
; CHECK-NEXT: br label [[FOR_BODY:%.*]] | ||
; CHECK: for.body: | ||
; CHECK-NEXT: store i32 [[X]], ptr [[ARRAY]], align 4 | ||
; CHECK-NEXT: [[ARRAYIDX_1:%.*]] = getelementptr inbounds i32, ptr [[ARRAY]], i64 1 | ||
; CHECK-NEXT: store i32 [[X]], ptr [[ARRAYIDX_1]], align 4 | ||
; CHECK-NEXT: [[ARRAYIDX_2:%.*]] = getelementptr inbounds i32, ptr [[ARRAY]], i64 2 | ||
; CHECK-NEXT: store i32 [[X]], ptr [[ARRAYIDX_2]], align 4 | ||
; CHECK-NEXT: [[ARRAYIDX_3:%.*]] = getelementptr inbounds i32, ptr [[ARRAY]], i64 3 | ||
; CHECK-NEXT: store i32 [[X]], ptr [[ARRAYIDX_3]], align 4 | ||
; CHECK-NEXT: ret void | ||
; | ||
entry: | ||
br label %for.body | ||
|
||
for.body: | ||
%indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ] | ||
%arrayidx = getelementptr inbounds i32, ptr %array, i64 %indvars.iv | ||
store i32 %x, ptr %arrayidx, align 4 | ||
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 | ||
%exitcond.not = icmp eq i64 %indvars.iv.next, 4 | ||
br i1 %exitcond.not, label %for.cond.cleanup, label %for.body | ||
|
||
for.cond.cleanup: | ||
ret void | ||
} | ||
|
||
attributes #0 = { optsize } |