-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Value] Look through inttoptr (add ..) in accumulateConstantOffsets #124981
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
@@ -1,30 +1,27 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: opt -p instcombine -S %s | FileCheck %s | ||
; RUN: opt -p instsimplify -S %s | FileCheck %s | ||
|
||
@glob = external global [314 x i64] | ||
|
||
define i1 @known_constexpr_add_eq() { | ||
; CHECK-LABEL: define i1 @known_constexpr_add_eq() { | ||
; CHECK-NEXT: [[COND:%.*]] = icmp eq ptr getelementptr inbounds nuw (i8, ptr @glob, i64 80), inttoptr (i64 add (i64 ptrtoint (ptr @glob to i64), i64 -80) to ptr) | ||
; CHECK-NEXT: ret i1 [[COND]] | ||
; CHECK-NEXT: ret i1 false | ||
; | ||
%cond = icmp eq ptr getelementptr inbounds nuw (i8, ptr @glob, i64 80), inttoptr (i64 add (i64 ptrtoint (ptr @glob to i64), i64 -80) to ptr) | ||
ret i1 %cond | ||
} | ||
|
||
define i1 @known_constexpr_add_eq_ops_swapped() { | ||
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. I don't get what the difference between this test and the previous is. What's swapped here? 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. Adjusted the name but not the code... fixed now, thanks |
||
; CHECK-LABEL: define i1 @known_constexpr_add_eq_ops_swapped() { | ||
; CHECK-NEXT: [[COND:%.*]] = icmp eq ptr getelementptr inbounds nuw (i8, ptr @glob, i64 80), inttoptr (i64 add (i64 ptrtoint (ptr @glob to i64), i64 -80) to ptr) | ||
; CHECK-NEXT: ret i1 [[COND]] | ||
; CHECK-NEXT: ret i1 false | ||
; | ||
%cond = icmp eq ptr getelementptr inbounds nuw (i8, ptr @glob, i64 80), inttoptr (i64 add (i64 ptrtoint (ptr @glob to i64), i64 -80) to ptr) | ||
%cond = icmp eq ptr inttoptr (i64 add (i64 ptrtoint (ptr @glob to i64), i64 -80) to ptr), getelementptr inbounds nuw (i8, ptr @glob, i64 80) | ||
ret i1 %cond | ||
} | ||
|
||
define i1 @known_constexpr_add_ne() { | ||
; CHECK-LABEL: define i1 @known_constexpr_add_ne() { | ||
; CHECK-NEXT: [[COND:%.*]] = icmp ne ptr getelementptr inbounds nuw (i8, ptr @glob, i64 80), inttoptr (i64 add (i64 ptrtoint (ptr @glob to i64), i64 -80) to ptr) | ||
; CHECK-NEXT: ret i1 [[COND]] | ||
; CHECK-NEXT: ret i1 true | ||
; | ||
%cond = icmp ne ptr getelementptr inbounds nuw (i8, ptr @glob, i64 80), inttoptr (i64 add (i64 ptrtoint (ptr @glob to i64), i64 -80) to ptr) | ||
ret i1 %cond | ||
|
@@ -41,8 +38,7 @@ define i1 @wrap_positive_to_negate() { | |
; 9223372036854775808 = 2^63 | ||
define i1 @wrap_positive_to_zero() { | ||
; CHECK-LABEL: define i1 @wrap_positive_to_zero() { | ||
; CHECK-NEXT: [[COND:%.*]] = icmp eq ptr @glob, inttoptr (i64 add (i64 ptrtoint (ptr getelementptr nuw (i8, ptr @glob, i64 -9223372036854775808) to i64), i64 -9223372036854775808) to ptr) | ||
; CHECK-NEXT: ret i1 [[COND]] | ||
; CHECK-NEXT: ret i1 true | ||
; | ||
%cond = icmp eq ptr @glob, inttoptr (i64 add (i64 ptrtoint (ptr getelementptr nuw (i8, ptr @glob, i64 9223372036854775808)to i64), i64 9223372036854775808) to ptr) | ||
ret i1 %cond | ||
|
@@ -99,3 +95,20 @@ define ptr @return_inttoptr() { | |
; | ||
ret ptr inttoptr (i64 add (i64 ptrtoint (ptr @glob to i64), i64 8) to ptr) | ||
} | ||
|
||
define i1 @known_constexpr_add_nested_1() { | ||
; CHECK-LABEL: define i1 @known_constexpr_add_nested_1() { | ||
; CHECK-NEXT: ret i1 true | ||
; | ||
%cond = icmp eq ptr @glob, inttoptr (i64 add (i64 ptrtoint (ptr getelementptr inbounds nuw (i8, ptr @glob, i64 80) to i64), i64 -80) to ptr) | ||
ret i1 %cond | ||
} | ||
|
||
define i1 @known_constexpr_add_nested_2() { | ||
; CHECK-LABEL: define i1 @known_constexpr_add_nested_2() { | ||
; CHECK-NEXT: ret i1 true | ||
; | ||
;%cond = icmp eq ptr @glob, ptr getelementptr inbounds nuw (i8, ptr inttoptr (i64 add (i64 ptrtoint (ptr @glob to i64), i64 -80) to ptr), i64 80) | ||
%cond = icmp eq ptr @glob, getelementptr inbounds nuw (i8, ptr inttoptr (i64 add (i64 ptrtoint (ptr @glob to i64), i64 -80) to ptr), i64 80) | ||
ret i1 %cond | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This test should either use
-p instsimplify
or be in theInstCombine
directory.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.
Originally I had it in instcombine, then moved but. not updated the run-line should be fixed now thanks