-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[DAGCombiner] Handle type-promoted constants in UDIV lowering #169491
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
base: main
Are you sure you want to change the base?
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 |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 | ||
| ; RUN: llc -mtriple=aarch64-none-linux-gnu < %s | FileCheck %s | ||
|
|
||
| ; This test verifies that udiv by constant works correctly even when type | ||
| ; legalization promotes constant operands (e.g., i16 -> i32 in BUILD_VECTOR). | ||
| ; This is a regression test for a bug where v16i16 would be split into two | ||
| ; v8i16 operations during legalization, the i16 constants would be promoted | ||
| ; to i32, and then the second DAGCombine round would fail to recognize the | ||
| ; promoted constants when trying to convert udiv into mul+shift. | ||
|
|
||
| define <8 x i16> @udiv_v8i16_by_255(<8 x i16> %x) { | ||
| ; CHECK-LABEL: udiv_v8i16_by_255: | ||
| ; CHECK: // %bb.0: | ||
| ; CHECK-NEXT: mov w8, #32897 // =0x8081 | ||
| ; CHECK-NEXT: dup v1.8h, w8 | ||
| ; CHECK-NEXT: umull2 v2.4s, v0.8h, v1.8h | ||
| ; CHECK-NEXT: umull v0.4s, v0.4h, v1.4h | ||
| ; CHECK-NEXT: uzp2 v0.8h, v0.8h, v2.8h | ||
| ; CHECK-NEXT: ushr v0.8h, v0.8h, #7 | ||
| ; CHECK-NEXT: ret | ||
| %div = udiv <8 x i16> %x, splat (i16 255) | ||
|
Contributor
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 understand why this is an issue for an example this trivial. I would expect this combine would fire in the pre-type-legalization combiner before the vector elements are promoted?
Member
Author
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. This example was working correctly. |
||
| ret <8 x i16> %div | ||
| } | ||
|
|
||
| define <16 x i16> @udiv_v16i16_by_255(<16 x i16> %x) { | ||
| ; CHECK-LABEL: udiv_v16i16_by_255: | ||
| ; CHECK: // %bb.0: | ||
| ; CHECK-NEXT: mov w8, #32897 // =0x8081 | ||
| ; CHECK-NEXT: dup v2.8h, w8 | ||
| ; CHECK-NEXT: umull2 v3.4s, v0.8h, v2.8h | ||
| ; CHECK-NEXT: umull v0.4s, v0.4h, v2.4h | ||
| ; CHECK-NEXT: umull2 v4.4s, v1.8h, v2.8h | ||
| ; CHECK-NEXT: umull v1.4s, v1.4h, v2.4h | ||
| ; CHECK-NEXT: uzp2 v0.8h, v0.8h, v3.8h | ||
| ; CHECK-NEXT: uzp2 v1.8h, v1.8h, v4.8h | ||
| ; CHECK-NEXT: ushr v0.8h, v0.8h, #7 | ||
| ; CHECK-NEXT: ushr v1.8h, v1.8h, #7 | ||
| ; CHECK-NEXT: ret | ||
| %div = udiv <16 x i16> %x, splat (i16 255) | ||
|
Collaborator
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. Can you add a similar test case for urem too. |
||
| ret <16 x i16> %div | ||
| } | ||
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.