-
Notifications
You must be signed in to change notification settings - Fork 13.8k
[SelectionDAG] Handle VSCALE in isKnownNeverZero #97789
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
Show all changes
3 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
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: llc < %s -mtriple=riscv64 -mattr=+v -verify-machineinstrs | FileCheck %s | ||
|
||
; Use cttz to test if we properly prove never-zero. There is a very | ||
; simple transform from cttz -> cttz_zero_undef if its operand is | ||
; known never zero. | ||
|
||
; Even without vscale_range, vscale is always guaranteed to be non-zero. | ||
define i32 @vscale_known_nonzero() { | ||
; CHECK-LABEL: vscale_known_nonzero: | ||
; CHECK: # %bb.0: | ||
; CHECK-NEXT: addi sp, sp, -16 | ||
; CHECK-NEXT: .cfi_def_cfa_offset 16 | ||
; CHECK-NEXT: sd ra, 8(sp) # 8-byte Folded Spill | ||
; CHECK-NEXT: .cfi_offset ra, -8 | ||
; CHECK-NEXT: csrr a0, vlenb | ||
; CHECK-NEXT: srli a0, a0, 3 | ||
; CHECK-NEXT: neg a1, a0 | ||
; CHECK-NEXT: and a0, a0, a1 | ||
; CHECK-NEXT: lui a1, 30667 | ||
; CHECK-NEXT: addiw a1, a1, 1329 | ||
; CHECK-NEXT: call __muldi3 | ||
; CHECK-NEXT: srliw a0, a0, 27 | ||
; CHECK-NEXT: lui a1, %hi(.LCPI0_0) | ||
; CHECK-NEXT: addi a1, a1, %lo(.LCPI0_0) | ||
; CHECK-NEXT: add a0, a1, a0 | ||
; CHECK-NEXT: lbu a0, 0(a0) | ||
; CHECK-NEXT: ld ra, 8(sp) # 8-byte Folded Reload | ||
; CHECK-NEXT: addi sp, sp, 16 | ||
; CHECK-NEXT: ret | ||
%x = call i32 @llvm.vscale() | ||
%r = call i32 @llvm.cttz.i32(i32 %x, i1 false) | ||
ret i32 %r | ||
} |
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.
I believe this check is incorrect. Consider a wrapping range of the form [4, 2]. This includes 0 despite the 0 not being the minimum element. The correct check here would be a contains check.
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.
Thanks for catching this, I was not aware ConstantRange could wrap. I've gone ahead and pushed a fix for this in baf22a5