-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[InstCombine] Support trunc to i1 in foldSelectICmpAnd #127905
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -809,8 +809,8 @@ define i8 @select_bittest_to_xor(i8 %x) { | |
|
||
define i8 @select_trunc_bittest_to_sub(i8 %x) { | ||
; CHECK-LABEL: @select_trunc_bittest_to_sub( | ||
; CHECK-NEXT: [[TRUNC:%.*]] = trunc i8 [[X:%.*]] to i1 | ||
; CHECK-NEXT: [[RET:%.*]] = select i1 [[TRUNC]], i8 3, i8 4 | ||
; CHECK-NEXT: [[TMP1:%.*]] = and i8 [[X:%.*]], 1 | ||
; CHECK-NEXT: [[RET:%.*]] = sub nuw nsw i8 4, [[TMP1]] | ||
; CHECK-NEXT: ret i8 [[RET]] | ||
; | ||
%trunc = trunc i8 %x to i1 | ||
|
@@ -820,8 +820,7 @@ define i8 @select_trunc_bittest_to_sub(i8 %x) { | |
|
||
define i8 @select_trunc_nuw_bittest_to_sub(i8 %x) { | ||
; CHECK-LABEL: @select_trunc_nuw_bittest_to_sub( | ||
; CHECK-NEXT: [[TRUNC:%.*]] = trunc nuw i8 [[X:%.*]] to i1 | ||
; CHECK-NEXT: [[RET:%.*]] = select i1 [[TRUNC]], i8 3, i8 4 | ||
; CHECK-NEXT: [[RET:%.*]] = sub i8 4, [[X:%.*]] | ||
; CHECK-NEXT: ret i8 [[RET]] | ||
; | ||
%trunc = trunc nuw i8 %x to i1 | ||
|
@@ -831,8 +830,8 @@ define i8 @select_trunc_nuw_bittest_to_sub(i8 %x) { | |
|
||
define i8 @select_trunc_nsw_bittest_to_sub(i8 %x) { | ||
; CHECK-LABEL: @select_trunc_nsw_bittest_to_sub( | ||
; CHECK-NEXT: [[TRUNC:%.*]] = trunc nsw i8 [[X:%.*]] to i1 | ||
; CHECK-NEXT: [[RET:%.*]] = select i1 [[TRUNC]], i8 3, i8 4 | ||
; CHECK-NEXT: [[TMP1:%.*]] = and i8 [[X:%.*]], 1 | ||
; CHECK-NEXT: [[RET:%.*]] = sub nuw nsw i8 4, [[TMP1]] | ||
; CHECK-NEXT: ret i8 [[RET]] | ||
; | ||
%trunc = trunc nsw i8 %x to i1 | ||
|
@@ -844,7 +843,7 @@ define i8 @select_trunc_nuw_bittest_to_sub_extra_use(i8 %x) { | |
; CHECK-LABEL: @select_trunc_nuw_bittest_to_sub_extra_use( | ||
; CHECK-NEXT: [[TRUNC:%.*]] = trunc nuw i8 [[X:%.*]] to i1 | ||
; CHECK-NEXT: call void @use1(i1 [[TRUNC]]) | ||
; CHECK-NEXT: [[RET:%.*]] = select i1 [[TRUNC]], i8 3, i8 4 | ||
; CHECK-NEXT: [[RET:%.*]] = sub i8 4, [[X]] | ||
; CHECK-NEXT: ret i8 [[RET]] | ||
; | ||
%trunc = trunc nuw i8 %x to i1 | ||
|
@@ -868,8 +867,8 @@ define i8 @neg_select_trunc_bittest_to_sub_extra_use(i8 %x) { | |
|
||
define i8 @select_trunc_nuw_bittest_to_shl_not(i8 %x) { | ||
; CHECK-LABEL: @select_trunc_nuw_bittest_to_shl_not( | ||
; CHECK-NEXT: [[TRUNC:%.*]] = trunc nuw i8 [[X:%.*]] to i1 | ||
; CHECK-NEXT: [[RET:%.*]] = select i1 [[TRUNC]], i8 0, i8 4 | ||
; CHECK-NEXT: [[TMP1:%.*]] = shl i8 [[X:%.*]], 2 | ||
; CHECK-NEXT: [[RET:%.*]] = xor i8 [[TMP1]], 4 | ||
; CHECK-NEXT: ret i8 [[RET]] | ||
; | ||
%trunc = trunc nuw i8 %x to i1 | ||
|
@@ -879,8 +878,8 @@ define i8 @select_trunc_nuw_bittest_to_shl_not(i8 %x) { | |
|
||
define i8 @select_trunc_bittest_to_shl(i8 %x) { | ||
; CHECK-LABEL: @select_trunc_bittest_to_shl( | ||
; CHECK-NEXT: [[TRUNC:%.*]] = trunc i8 [[X:%.*]] to i1 | ||
; CHECK-NEXT: [[RET:%.*]] = select i1 [[TRUNC]], i8 4, i8 0 | ||
; CHECK-NEXT: [[TMP1:%.*]] = shl i8 [[X:%.*]], 2 | ||
; CHECK-NEXT: [[RET:%.*]] = and i8 [[TMP1]], 4 | ||
; CHECK-NEXT: ret i8 [[RET]] | ||
; | ||
%trunc = trunc i8 %x to i1 | ||
|
@@ -903,8 +902,9 @@ define i8 @neg_select_trunc_bittest_to_shl_extra_use(i8 %x) { | |
|
||
define i16 @select_trunc_nuw_bittest_or(i8 %x) { | ||
; CHECK-LABEL: @select_trunc_nuw_bittest_or( | ||
; CHECK-NEXT: [[TMP1:%.*]] = trunc nuw i8 [[X:%.*]] to i1 | ||
; CHECK-NEXT: [[RES:%.*]] = select i1 [[TMP1]], i16 20, i16 4 | ||
; CHECK-NEXT: [[TMP1:%.*]] = zext i8 [[X:%.*]] to i16 | ||
; CHECK-NEXT: [[SELECT:%.*]] = shl nuw nsw i16 [[TMP1]], 4 | ||
; CHECK-NEXT: [[RES:%.*]] = or disjoint i16 [[SELECT]], 4 | ||
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. It is not a regression. The codegen without select is generally better: https://godbolt.org/z/1W6ocqdT3 |
||
; CHECK-NEXT: ret i16 [[RES]] | ||
; | ||
%trunc = trunc nuw i8 %x to i1 | ||
|
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.