-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[FuncSpec] Consider literal constants of recursive functions #111162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,7 +51,7 @@ entry: | |
; CHECK-NEXT: [[ENTRY:.*:]] | ||
; CHECK-NEXT: br i1 [[FLAG]], label %[[PLUS:.*]], label %[[MINUS:.*]] | ||
; CHECK: [[PLUS]]: | ||
; CHECK-NEXT: [[CMP0:%.*]] = call i64 @compute.specialized.2(i64 [[X]], i64 [[Y]], ptr @plus, ptr @minus) | ||
; CHECK-NEXT: [[CMP0:%.*]] = call i64 @compute.specialized.1(i64 [[X]], i64 [[Y]], ptr @plus, ptr @minus) | ||
; CHECK-NEXT: br label %[[MERGE:.*]] | ||
; CHECK: [[MINUS]]: | ||
; CHECK-NEXT: [[CMP1:%.*]] = call i64 @compute.specialized.3(i64 [[X]], i64 [[Y]], ptr @minus, ptr @plus) | ||
|
@@ -79,10 +79,10 @@ entry: | |
; CHECK-LABEL: define internal i64 @compute.specialized.1( | ||
; CHECK-SAME: i64 [[X:%.*]], i64 [[Y:%.*]], ptr [[BINOP1:%.*]], ptr [[BINOP2:%.*]]) { | ||
; CHECK-NEXT: [[ENTRY:.*:]] | ||
; CHECK-NEXT: [[OP1:%.*]] = call i64 [[BINOP1]](i64 [[X]], i64 [[Y]]) | ||
; CHECK-NEXT: [[OP0:%.*]] = call i64 @plus(i64 [[X]], i64 [[Y]]) | ||
; CHECK-NEXT: [[OP2:%.*]] = call i64 @compute.specialized.1(i64 [[X]], i64 [[Y]], ptr [[BINOP1]], ptr @plus) | ||
; CHECK-NEXT: [[ADD0:%.*]] = add i64 [[OP1]], [[OP0]] | ||
; CHECK-NEXT: [[OP1:%.*]] = call i64 @minus(i64 [[X]], i64 [[Y]]) | ||
; CHECK-NEXT: [[OP2:%.*]] = call i64 @compute.specialized.5(i64 [[X]], i64 [[Y]], ptr @plus, ptr @plus) | ||
; CHECK-NEXT: [[ADD0:%.*]] = add i64 [[OP0]], [[OP1]] | ||
; CHECK-NEXT: [[ADD1:%.*]] = add i64 [[ADD0]], [[OP2]] | ||
; CHECK-NEXT: [[DIV:%.*]] = sdiv i64 [[ADD1]], [[X]] | ||
; CHECK-NEXT: [[SUB:%.*]] = sub i64 [[DIV]], [[Y]] | ||
|
@@ -93,13 +93,13 @@ entry: | |
; CHECK-LABEL: define internal i64 @compute.specialized.2( | ||
; CHECK-SAME: i64 [[X:%.*]], i64 [[Y:%.*]], ptr [[BINOP1:%.*]], ptr [[BINOP2:%.*]]) { | ||
; CHECK-NEXT: [[ENTRY:.*:]] | ||
; CHECK-NEXT: [[OP0:%.*]] = call i64 @plus(i64 [[X]], i64 [[Y]]) | ||
; CHECK-NEXT: [[OP1:%.*]] = call i64 @minus(i64 [[X]], i64 [[Y]]) | ||
; CHECK-NEXT: [[OP2:%.*]] = call i64 @compute.specialized.1(i64 [[X]], i64 [[Y]], ptr @plus, ptr @plus) | ||
; CHECK-NEXT: [[OP0:%.*]] = call i64 @plus(i64 [[X]], i64 42) | ||
; CHECK-NEXT: [[OP1:%.*]] = call i64 @minus(i64 [[X]], i64 42) | ||
; CHECK-NEXT: [[OP2:%.*]] = call i64 @compute.specialized.4(i64 [[X]], i64 42, ptr @plus, ptr @plus) | ||
; CHECK-NEXT: [[ADD0:%.*]] = add i64 [[OP0]], [[OP1]] | ||
; CHECK-NEXT: [[ADD1:%.*]] = add i64 [[ADD0]], [[OP2]] | ||
; CHECK-NEXT: [[DIV:%.*]] = sdiv i64 [[ADD1]], [[X]] | ||
; CHECK-NEXT: [[SUB:%.*]] = sub i64 [[DIV]], [[Y]] | ||
; CHECK-NEXT: [[SUB:%.*]] = sub i64 [[DIV]], 42 | ||
; CHECK-NEXT: [[MUL:%.*]] = mul i64 [[SUB]], 2 | ||
; CHECK-NEXT: ret i64 [[MUL]] | ||
; | ||
|
@@ -117,3 +117,45 @@ entry: | |
; CHECK-NEXT: [[MUL:%.*]] = mul i64 [[SUB]], 2 | ||
; CHECK-NEXT: ret i64 [[MUL]] | ||
; | ||
; | ||
; CHECK-LABEL: define internal i64 @compute.specialized.4( | ||
; CHECK-SAME: i64 [[X:%.*]], i64 [[Y:%.*]], ptr [[BINOP1:%.*]], ptr [[BINOP2:%.*]]) { | ||
; CHECK-NEXT: [[ENTRY:.*:]] | ||
; CHECK-NEXT: [[OP0:%.*]] = call i64 @plus(i64 [[X]], i64 42) | ||
; CHECK-NEXT: [[OP1:%.*]] = call i64 @plus(i64 [[X]], i64 42) | ||
; CHECK-NEXT: [[OP2:%.*]] = call i64 @compute.specialized.4(i64 [[X]], i64 42, ptr @plus, ptr @plus) | ||
; CHECK-NEXT: [[ADD0:%.*]] = add i64 [[OP0]], [[OP1]] | ||
; CHECK-NEXT: [[ADD1:%.*]] = add i64 [[ADD0]], [[OP2]] | ||
; CHECK-NEXT: [[DIV:%.*]] = sdiv i64 [[ADD1]], [[X]] | ||
; CHECK-NEXT: [[SUB:%.*]] = sub i64 [[DIV]], 42 | ||
; CHECK-NEXT: [[MUL:%.*]] = mul i64 [[SUB]], 2 | ||
; CHECK-NEXT: ret i64 [[MUL]] | ||
; | ||
; | ||
; CHECK-LABEL: define internal i64 @compute.specialized.5( | ||
; CHECK-SAME: i64 [[X:%.*]], i64 [[Y:%.*]], ptr [[BINOP1:%.*]], ptr [[BINOP2:%.*]]) { | ||
; CHECK-NEXT: [[ENTRY:.*:]] | ||
; CHECK-NEXT: [[OP0:%.*]] = call i64 @plus(i64 [[X]], i64 [[Y]]) | ||
; CHECK-NEXT: [[OP1:%.*]] = call i64 @plus(i64 [[X]], i64 [[Y]]) | ||
; CHECK-NEXT: [[OP2:%.*]] = call i64 @compute.specialized.5(i64 [[X]], i64 [[Y]], ptr @plus, ptr @plus) | ||
; CHECK-NEXT: [[ADD0:%.*]] = add i64 [[OP0]], [[OP1]] | ||
; CHECK-NEXT: [[ADD1:%.*]] = add i64 [[ADD0]], [[OP2]] | ||
; CHECK-NEXT: [[DIV:%.*]] = sdiv i64 [[ADD1]], [[X]] | ||
; CHECK-NEXT: [[SUB:%.*]] = sub i64 [[DIV]], [[Y]] | ||
; CHECK-NEXT: [[MUL:%.*]] = mul i64 [[SUB]], 2 | ||
; CHECK-NEXT: ret i64 [[MUL]] | ||
; | ||
; | ||
; CHECK-LABEL: define internal i64 @compute.specialized.6( | ||
; CHECK-SAME: i64 [[X:%.*]], i64 [[Y:%.*]], ptr [[BINOP1:%.*]], ptr [[BINOP2:%.*]]) { | ||
; CHECK-NEXT: [[ENTRY:.*:]] | ||
; CHECK-NEXT: [[OP0:%.*]] = call i64 [[BINOP1]](i64 [[X]], i64 [[Y]]) | ||
; CHECK-NEXT: [[OP1:%.*]] = call i64 @plus(i64 [[X]], i64 [[Y]]) | ||
; CHECK-NEXT: [[OP2:%.*]] = call i64 @compute.specialized.6(i64 [[X]], i64 [[Y]], ptr [[BINOP1]], ptr @plus) | ||
; CHECK-NEXT: [[ADD0:%.*]] = add i64 [[OP0]], [[OP1]] | ||
; CHECK-NEXT: [[ADD1:%.*]] = add i64 [[ADD0]], [[OP2]] | ||
; CHECK-NEXT: [[DIV:%.*]] = sdiv i64 [[ADD1]], [[X]] | ||
; CHECK-NEXT: [[SUB:%.*]] = sub i64 [[DIV]], [[Y]] | ||
; CHECK-NEXT: [[MUL:%.*]] = mul i64 [[SUB]], 2 | ||
; CHECK-NEXT: ret i64 [[MUL]] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Same here |
||
; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any new tests should be moved to a new file named accordingly based on what the test is trying to check. In this case something like
recursive-literal-const-args.ll
or similar.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I've realised you're not adding tests but changing the codegen of existing ones. That doesn't seem right, I'd change the RUN lines of this file to prevent specialization on literal constants.