-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[CodeGen] Avoid sinking vector comparisons during CodeGenPrepare #113158
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
Closed
Closed
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
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
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
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,151 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: llc < %s | FileCheck %s | ||
|
||
target triple = "aarch64-unknown-linux-gnu" | ||
|
||
define <4 x i32> @no_sink_simple(<4 x i32> %a, <4 x i32> %b, i1 %c, ptr %p) { | ||
; CHECK-LABEL: no_sink_simple: | ||
; CHECK: // %bb.0: | ||
; CHECK-NEXT: cmgt v2.4s, v1.4s, v0.4s | ||
; CHECK-NEXT: xtn v2.4h, v2.4s | ||
; CHECK-NEXT: tbz w0, #0, .LBB0_2 | ||
; CHECK-NEXT: // %bb.1: // %s | ||
; CHECK-NEXT: sshll v1.4s, v2.4h, #0 | ||
; CHECK-NEXT: and v0.16b, v0.16b, v1.16b | ||
; CHECK-NEXT: str q0, [x1] | ||
; CHECK-NEXT: ret | ||
; CHECK-NEXT: .LBB0_2: // %t | ||
; CHECK-NEXT: sshll v0.4s, v2.4h, #0 | ||
; CHECK-NEXT: and v0.16b, v1.16b, v0.16b | ||
; CHECK-NEXT: ret | ||
%d = icmp slt <4 x i32> %a, %b | ||
br i1 %c, label %s, label %t | ||
|
||
s: | ||
%s1 = select <4 x i1> %d, <4 x i32> %a, <4 x i32> zeroinitializer | ||
store <4 x i32> %s1, ptr %p | ||
ret <4 x i32> %s1 | ||
|
||
t: | ||
%s2 = select <4 x i1> %d, <4 x i32> %b, <4 x i32> zeroinitializer | ||
ret <4 x i32> %s2 | ||
} | ||
|
||
define void @vector_loop_with_icmp(ptr nocapture noundef writeonly %dest) { | ||
; CHECK-LABEL: vector_loop_with_icmp: | ||
; CHECK: // %bb.0: // %entry | ||
; CHECK-NEXT: mov w9, #15 // =0xf | ||
; CHECK-NEXT: mov w10, #4 // =0x4 | ||
; CHECK-NEXT: adrp x8, .LCPI1_0 | ||
; CHECK-NEXT: adrp x11, .LCPI1_1 | ||
; CHECK-NEXT: dup v0.2d, x9 | ||
; CHECK-NEXT: dup v1.2d, x10 | ||
; CHECK-NEXT: ldr q2, [x8, :lo12:.LCPI1_0] | ||
; CHECK-NEXT: ldr q3, [x11, :lo12:.LCPI1_1] | ||
; CHECK-NEXT: add x8, x0, #8 | ||
; CHECK-NEXT: mov w9, #16 // =0x10 | ||
; CHECK-NEXT: mov w10, #1 // =0x1 | ||
; CHECK-NEXT: b .LBB1_2 | ||
; CHECK-NEXT: .LBB1_1: // %pred.store.continue18 | ||
; CHECK-NEXT: // in Loop: Header=BB1_2 Depth=1 | ||
; CHECK-NEXT: add v2.2d, v2.2d, v1.2d | ||
; CHECK-NEXT: add v3.2d, v3.2d, v1.2d | ||
; CHECK-NEXT: subs x9, x9, #4 | ||
; CHECK-NEXT: add x8, x8, #16 | ||
; CHECK-NEXT: b.eq .LBB1_10 | ||
; CHECK-NEXT: .LBB1_2: // %vector.body | ||
; CHECK-NEXT: // =>This Inner Loop Header: Depth=1 | ||
; CHECK-NEXT: cmhi v4.2d, v0.2d, v2.2d | ||
; CHECK-NEXT: cmhi v5.2d, v0.2d, v3.2d | ||
; CHECK-NEXT: uzp1 v4.4s, v5.4s, v4.4s | ||
; CHECK-NEXT: xtn v4.4h, v4.4s | ||
; CHECK-NEXT: umov w11, v4.h[0] | ||
; CHECK-NEXT: tbnz w11, #0, .LBB1_6 | ||
; CHECK-NEXT: // %bb.3: // %pred.store.continue | ||
; CHECK-NEXT: // in Loop: Header=BB1_2 Depth=1 | ||
; CHECK-NEXT: umov w11, v4.h[1] | ||
; CHECK-NEXT: tbnz w11, #0, .LBB1_7 | ||
; CHECK-NEXT: .LBB1_4: // %pred.store.continue6 | ||
; CHECK-NEXT: // in Loop: Header=BB1_2 Depth=1 | ||
; CHECK-NEXT: umov w11, v4.h[2] | ||
; CHECK-NEXT: tbnz w11, #0, .LBB1_8 | ||
; CHECK-NEXT: .LBB1_5: // %pred.store.continue8 | ||
; CHECK-NEXT: // in Loop: Header=BB1_2 Depth=1 | ||
; CHECK-NEXT: umov w11, v4.h[3] | ||
; CHECK-NEXT: tbz w11, #0, .LBB1_1 | ||
; CHECK-NEXT: b .LBB1_9 | ||
; CHECK-NEXT: .LBB1_6: // %pred.store.if | ||
; CHECK-NEXT: // in Loop: Header=BB1_2 Depth=1 | ||
; CHECK-NEXT: stur w10, [x8, #-8] | ||
; CHECK-NEXT: umov w11, v4.h[1] | ||
; CHECK-NEXT: tbz w11, #0, .LBB1_4 | ||
; CHECK-NEXT: .LBB1_7: // %pred.store.if5 | ||
; CHECK-NEXT: // in Loop: Header=BB1_2 Depth=1 | ||
; CHECK-NEXT: stur w10, [x8, #-4] | ||
; CHECK-NEXT: umov w11, v4.h[2] | ||
; CHECK-NEXT: tbz w11, #0, .LBB1_5 | ||
; CHECK-NEXT: .LBB1_8: // %pred.store.if7 | ||
; CHECK-NEXT: // in Loop: Header=BB1_2 Depth=1 | ||
; CHECK-NEXT: str w10, [x8] | ||
; CHECK-NEXT: umov w11, v4.h[3] | ||
; CHECK-NEXT: tbz w11, #0, .LBB1_1 | ||
; CHECK-NEXT: .LBB1_9: // %pred.store.if9 | ||
; CHECK-NEXT: // in Loop: Header=BB1_2 Depth=1 | ||
; CHECK-NEXT: str w10, [x8, #4] | ||
; CHECK-NEXT: b .LBB1_1 | ||
; CHECK-NEXT: .LBB1_10: // %for.cond.cleanup | ||
; CHECK-NEXT: ret | ||
entry: | ||
br label %vector.body | ||
|
||
vector.body: | ||
%index = phi i64 [ 0, %entry ], [ %index.next, %pred.store.continue18 ] | ||
%vec.ind = phi <4 x i64> [ <i64 0, i64 1, i64 2, i64 3>, %entry ], [ %vec.ind.next, %pred.store.continue18 ] | ||
%0 = icmp ult <4 x i64> %vec.ind, <i64 15, i64 15, i64 15, i64 15> | ||
%1 = extractelement <4 x i1> %0, i64 0 | ||
br i1 %1, label %pred.store.if, label %pred.store.continue | ||
|
||
pred.store.if: | ||
%2 = getelementptr inbounds i32, ptr %dest, i64 %index | ||
store i32 1, ptr %2, align 4 | ||
br label %pred.store.continue | ||
|
||
pred.store.continue: | ||
%3 = extractelement <4 x i1> %0, i64 1 | ||
br i1 %3, label %pred.store.if5, label %pred.store.continue6 | ||
|
||
pred.store.if5: | ||
%4 = or disjoint i64 %index, 1 | ||
%5 = getelementptr inbounds i32, ptr %dest, i64 %4 | ||
store i32 1, ptr %5, align 4 | ||
br label %pred.store.continue6 | ||
|
||
pred.store.continue6: | ||
%6 = extractelement <4 x i1> %0, i64 2 | ||
br i1 %6, label %pred.store.if7, label %pred.store.continue8 | ||
|
||
pred.store.if7: | ||
%7 = or disjoint i64 %index, 2 | ||
%8 = getelementptr inbounds i32, ptr %dest, i64 %7 | ||
store i32 1, ptr %8, align 4 | ||
br label %pred.store.continue8 | ||
|
||
pred.store.continue8: | ||
%9 = extractelement <4 x i1> %0, i64 3 | ||
br i1 %9, label %pred.store.if9, label %pred.store.continue18 | ||
|
||
pred.store.if9: | ||
%10 = or disjoint i64 %index, 3 | ||
%11 = getelementptr inbounds i32, ptr %dest, i64 %10 | ||
store i32 1, ptr %11, align 4 | ||
br label %pred.store.continue18 | ||
|
||
pred.store.continue18: | ||
%index.next = add i64 %index, 4 | ||
%vec.ind.next = add <4 x i64> %vec.ind, <i64 4, i64 4, i64 4, i64 4> | ||
%24 = icmp eq i64 %index.next, 16 | ||
br i1 %24, label %for.cond.cleanup, label %vector.body | ||
|
||
for.cond.cleanup: | ||
ret void | ||
} |
Oops, something went wrong.
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.
AMDGPU part looks fine. In future we will probably want to address this FIXME by passing in a node, not just a type.