-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[DivRemPairs] Pre-commit tests for PR #92627 #92628
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
krzysz00
merged 2 commits into
llvm:main
from
krzysz00:div-rem-pairs-undef-only-pre-commit
May 20, 2024
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
141 changes: 141 additions & 0 deletions
141
llvm/test/Transforms/DivRemPairs/AMDGPU/div-rem-pairs.ll
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 |
---|---|---|
@@ -0,0 +1,141 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4 | ||
; RUN: opt < %s -passes=div-rem-pairs -S -mtriple=amdgcn-amd-amdhsa | FileCheck %s | ||
|
||
define i32 @basic(ptr %p, i32 %x, i32 %y) { | ||
; CHECK-LABEL: define i32 @basic( | ||
; CHECK-SAME: ptr [[P:%.*]], i32 [[X:%.*]], i32 [[Y:%.*]]) { | ||
; CHECK-NEXT: [[X_FROZEN:%.*]] = freeze i32 [[X]] | ||
; CHECK-NEXT: [[Y_FROZEN:%.*]] = freeze i32 [[Y]] | ||
; CHECK-NEXT: [[DIV:%.*]] = udiv i32 [[X_FROZEN]], [[Y_FROZEN]] | ||
; CHECK-NEXT: [[TMP1:%.*]] = mul i32 [[DIV]], [[Y_FROZEN]] | ||
; CHECK-NEXT: [[REM_DECOMPOSED:%.*]] = sub i32 [[X_FROZEN]], [[TMP1]] | ||
; CHECK-NEXT: store i32 [[DIV]], ptr [[P]], align 4 | ||
; CHECK-NEXT: ret i32 [[REM_DECOMPOSED]] | ||
; | ||
%div = udiv i32 %x, %y | ||
%rem = urem i32 %x, %y | ||
store i32 %div, ptr %p, align 4 | ||
ret i32 %rem | ||
} | ||
|
||
define i32 @no_freezes(ptr %p, i32 noundef %x, i32 noundef %y) { | ||
; CHECK-LABEL: define i32 @no_freezes( | ||
; CHECK-SAME: ptr [[P:%.*]], i32 noundef [[X:%.*]], i32 noundef [[Y:%.*]]) { | ||
; CHECK-NEXT: [[DIV:%.*]] = udiv i32 [[X]], [[Y]] | ||
; CHECK-NEXT: [[TMP1:%.*]] = mul i32 [[DIV]], [[Y]] | ||
; CHECK-NEXT: [[REM_DECOMPOSED:%.*]] = sub i32 [[X]], [[TMP1]] | ||
; CHECK-NEXT: store i32 [[DIV]], ptr [[P]], align 4 | ||
; CHECK-NEXT: ret i32 [[REM_DECOMPOSED]] | ||
; | ||
%div = udiv i32 %x, %y | ||
%rem = urem i32 %x, %y | ||
store i32 %div, ptr %p, align 4 | ||
ret i32 %rem | ||
} | ||
|
||
; FIXME: There should be no need to `freeze` x2 and y2 since they have defined | ||
; but potentially poison values. | ||
define i32 @poison_does_not_freeze(ptr %p, i32 noundef %x, i32 noundef %y) { | ||
; CHECK-LABEL: define i32 @poison_does_not_freeze( | ||
; CHECK-SAME: ptr [[P:%.*]], i32 noundef [[X:%.*]], i32 noundef [[Y:%.*]]) { | ||
; CHECK-NEXT: [[X2:%.*]] = shl nuw nsw i32 [[X]], 5 | ||
; CHECK-NEXT: [[Y2:%.*]] = add nuw nsw i32 [[Y]], 1 | ||
; CHECK-NEXT: [[X2_FROZEN:%.*]] = freeze i32 [[X2]] | ||
; CHECK-NEXT: [[Y2_FROZEN:%.*]] = freeze i32 [[Y2]] | ||
; CHECK-NEXT: [[DIV:%.*]] = udiv i32 [[X2_FROZEN]], [[Y2_FROZEN]] | ||
; CHECK-NEXT: [[TMP1:%.*]] = mul i32 [[DIV]], [[Y2_FROZEN]] | ||
; CHECK-NEXT: [[REM_DECOMPOSED:%.*]] = sub i32 [[X2_FROZEN]], [[TMP1]] | ||
; CHECK-NEXT: store i32 [[DIV]], ptr [[P]], align 4 | ||
; CHECK-NEXT: ret i32 [[REM_DECOMPOSED]] | ||
; | ||
%x2 = shl nuw nsw i32 %x, 5 | ||
%y2 = add nuw nsw i32 %y, 1 | ||
%div = udiv i32 %x2, %y2 | ||
%rem = urem i32 %x2, %y2 | ||
store i32 %div, ptr %p, align 4 | ||
ret i32 %rem | ||
} | ||
|
||
define i32 @poison_does_not_freeze_signed(ptr %p, i32 noundef %x, i32 noundef %y) { | ||
; CHECK-LABEL: define i32 @poison_does_not_freeze_signed( | ||
; CHECK-SAME: ptr [[P:%.*]], i32 noundef [[X:%.*]], i32 noundef [[Y:%.*]]) { | ||
; CHECK-NEXT: [[X2:%.*]] = shl nuw nsw i32 [[X]], 5 | ||
; CHECK-NEXT: [[Y2:%.*]] = add nuw nsw i32 [[Y]], 1 | ||
; CHECK-NEXT: [[X2_FROZEN:%.*]] = freeze i32 [[X2]] | ||
; CHECK-NEXT: [[Y2_FROZEN:%.*]] = freeze i32 [[Y2]] | ||
; CHECK-NEXT: [[DIV:%.*]] = sdiv i32 [[X2_FROZEN]], [[Y2_FROZEN]] | ||
; CHECK-NEXT: [[TMP1:%.*]] = mul i32 [[DIV]], [[Y2_FROZEN]] | ||
; CHECK-NEXT: [[REM_DECOMPOSED:%.*]] = sub i32 [[X2_FROZEN]], [[TMP1]] | ||
; CHECK-NEXT: store i32 [[DIV]], ptr [[P]], align 4 | ||
; CHECK-NEXT: ret i32 [[REM_DECOMPOSED]] | ||
; | ||
%x2 = shl nuw nsw i32 %x, 5 | ||
%y2 = add nuw nsw i32 %y, 1 | ||
%div = sdiv i32 %x2, %y2 | ||
%rem = srem i32 %x2, %y2 | ||
store i32 %div, ptr %p, align 4 | ||
ret i32 %rem | ||
} | ||
|
||
define <4 x i8> @poison_does_not_freeze_vector(ptr %p, <4 x i8> noundef %x, <4 x i8> noundef %y) { | ||
; CHECK-LABEL: define <4 x i8> @poison_does_not_freeze_vector( | ||
; CHECK-SAME: ptr [[P:%.*]], <4 x i8> noundef [[X:%.*]], <4 x i8> noundef [[Y:%.*]]) { | ||
; CHECK-NEXT: [[X2:%.*]] = shl nuw nsw <4 x i8> [[X]], <i8 5, i8 5, i8 5, i8 5> | ||
; CHECK-NEXT: [[Y2:%.*]] = add nuw nsw <4 x i8> [[Y]], <i8 1, i8 1, i8 1, i8 1> | ||
; CHECK-NEXT: [[X2_FROZEN:%.*]] = freeze <4 x i8> [[X2]] | ||
; CHECK-NEXT: [[Y2_FROZEN:%.*]] = freeze <4 x i8> [[Y2]] | ||
; CHECK-NEXT: [[DIV:%.*]] = udiv <4 x i8> [[X2_FROZEN]], [[Y2_FROZEN]] | ||
; CHECK-NEXT: [[TMP1:%.*]] = mul <4 x i8> [[DIV]], [[Y2_FROZEN]] | ||
; CHECK-NEXT: [[REM_DECOMPOSED:%.*]] = sub <4 x i8> [[X2_FROZEN]], [[TMP1]] | ||
; CHECK-NEXT: store <4 x i8> [[DIV]], ptr [[P]], align 4 | ||
; CHECK-NEXT: ret <4 x i8> [[REM_DECOMPOSED]] | ||
; | ||
%x2 = shl nuw nsw <4 x i8> %x, <i8 5, i8 5, i8 5, i8 5> | ||
%y2 = add nuw nsw <4 x i8> %y, <i8 1, i8 1, i8 1, i8 1> | ||
%div = udiv <4 x i8> %x2, %y2 | ||
%rem = urem <4 x i8> %x2, %y2 | ||
store <4 x i8> %div, ptr %p, align 4 | ||
ret <4 x i8> %rem | ||
} | ||
|
||
define i32 @explicit_poison_does_not_freeze(ptr %p, i32 noundef %y) { | ||
; CHECK-LABEL: define i32 @explicit_poison_does_not_freeze( | ||
; CHECK-SAME: ptr [[P:%.*]], i32 noundef [[Y:%.*]]) { | ||
; CHECK-NEXT: [[X:%.*]] = add i32 poison, 1 | ||
; CHECK-NEXT: [[Y2:%.*]] = add nuw nsw i32 [[Y]], 1 | ||
; CHECK-NEXT: [[X_FROZEN:%.*]] = freeze i32 [[X]] | ||
; CHECK-NEXT: [[Y2_FROZEN:%.*]] = freeze i32 [[Y2]] | ||
; CHECK-NEXT: [[DIV:%.*]] = udiv i32 [[X_FROZEN]], [[Y2_FROZEN]] | ||
; CHECK-NEXT: [[TMP1:%.*]] = mul i32 [[DIV]], [[Y2_FROZEN]] | ||
; CHECK-NEXT: [[REM_DECOMPOSED:%.*]] = sub i32 [[X_FROZEN]], [[TMP1]] | ||
; CHECK-NEXT: store i32 [[DIV]], ptr [[P]], align 4 | ||
; CHECK-NEXT: ret i32 [[REM_DECOMPOSED]] | ||
; | ||
%x = add i32 poison, 1 | ||
%y2 = add nuw nsw i32 %y, 1 | ||
%div = udiv i32 %x, %y2 | ||
%rem = urem i32 %x, %y2 | ||
store i32 %div, ptr %p, align 4 | ||
ret i32 %rem | ||
} | ||
|
||
define i32 @explicit_poison_does_not_freeze_signed(ptr %p, i32 noundef %y) { | ||
; CHECK-LABEL: define i32 @explicit_poison_does_not_freeze_signed( | ||
; CHECK-SAME: ptr [[P:%.*]], i32 noundef [[Y:%.*]]) { | ||
; CHECK-NEXT: [[X:%.*]] = add i32 poison, 1 | ||
; CHECK-NEXT: [[Y2:%.*]] = add nuw nsw i32 [[Y]], 1 | ||
; CHECK-NEXT: [[X_FROZEN:%.*]] = freeze i32 [[X]] | ||
; CHECK-NEXT: [[Y2_FROZEN:%.*]] = freeze i32 [[Y2]] | ||
; CHECK-NEXT: [[DIV:%.*]] = sdiv i32 [[X_FROZEN]], [[Y2_FROZEN]] | ||
; CHECK-NEXT: [[TMP1:%.*]] = mul i32 [[DIV]], [[Y2_FROZEN]] | ||
; CHECK-NEXT: [[REM_DECOMPOSED:%.*]] = sub i32 [[X_FROZEN]], [[TMP1]] | ||
; CHECK-NEXT: store i32 [[DIV]], ptr [[P]], align 4 | ||
; CHECK-NEXT: ret i32 [[REM_DECOMPOSED]] | ||
; | ||
%x = add i32 poison, 1 | ||
%y2 = add nuw nsw i32 %y, 1 | ||
%div = sdiv i32 %x, %y2 | ||
%rem = srem i32 %x, %y2 | ||
store i32 %div, ptr %p, align 4 | ||
ret i32 %rem | ||
} |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
if not "AMDGPU" in config.root.targets: | ||
config.unsupported = True |
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.
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.
Maybe test a vector case. Also should test the sdiv/srem cases