-
Notifications
You must be signed in to change notification settings - Fork 13.3k
[X86][AVX512] Use comx for compare #113567
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 6 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
09d1f74
update compare opt
44baff2
add test
d242ba8
update mod
f56ad5c
add legal CC in 10.2
cdd0050
remove space
6aa7edf
update review comment
92c9471
remove space
da9493c
update review comments faulty commit
1f7b326
Revert "update review comments faulty commit"
55edbe3
update review comments
9f2241b
add f16
857bbe3
remove space
a855acd
Merge branch 'main' into comefopt_2
mahesh-attarde 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -223,6 +223,12 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM, | |
setCondCodeAction(ISD::SETUNE, VT, Expand); | ||
} | ||
|
||
if (Subtarget.hasAVX10_2()) { | ||
for (auto VT : {MVT::f32, MVT::f64}) { | ||
setCondCodeAction(ISD::SETOEQ, VT, Custom); | ||
setCondCodeAction(ISD::SETUNE, VT, Custom); | ||
} | ||
} | ||
// Integer absolute. | ||
if (Subtarget.canUseCMOV()) { | ||
setOperationAction(ISD::ABS , MVT::i16 , Custom); | ||
|
@@ -2292,8 +2298,10 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM, | |
setOperationAction(ISD::FP_EXTEND, MVT::f32, Legal); | ||
setOperationAction(ISD::STRICT_FP_EXTEND, MVT::f32, Legal); | ||
|
||
setCondCodeAction(ISD::SETOEQ, MVT::f16, Expand); | ||
setCondCodeAction(ISD::SETUNE, MVT::f16, Expand); | ||
setCondCodeAction(ISD::SETOEQ, MVT::f16, | ||
Subtarget.hasAVX10_2() ? Custom : Expand); | ||
setCondCodeAction(ISD::SETUNE, MVT::f16, | ||
Subtarget.hasAVX10_2() ? Custom : Expand); | ||
|
||
if (Subtarget.useAVX512Regs()) { | ||
setGroup(MVT::v32f16); | ||
|
@@ -2442,7 +2450,6 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM, | |
} | ||
} | ||
} | ||
|
||
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. Unrelated change. |
||
if (!Subtarget.useSoftFloat() && Subtarget.hasVLX()) { | ||
setTruncStoreAction(MVT::v4i64, MVT::v4i8, Legal); | ||
setTruncStoreAction(MVT::v4i64, MVT::v4i16, Legal); | ||
|
@@ -24073,6 +24080,13 @@ SDValue X86TargetLowering::LowerSETCC(SDValue Op, SelectionDAG &DAG) const { | |
return IsStrict ? DAG.getMergeValues({Res, Chain}, dl) : Res; | ||
} | ||
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.
|
||
|
||
if (Subtarget.hasAVX10_2()) { | ||
if (CC == ISD::SETOEQ || CC == ISD::SETUNE) { | ||
auto NewCC = (CC == ISD::SETOEQ) ? X86::COND_E : (X86::COND_NE); | ||
return getSETCC(NewCC, DAG.getNode(X86ISD::UCOMX, dl, MVT::i32, Op0, Op1), | ||
dl, DAG); | ||
} | ||
} | ||
// Handle floating point. | ||
X86::CondCode CondCode = TranslateX86CC(CC, dl, /*IsFP*/ true, Op0, Op1, DAG); | ||
if (CondCode == X86::COND_INVALID) | ||
|
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,237 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx10.2-256 | FileCheck %s --check-prefix=X64 | ||
; RUN: llc < %s -mtriple=i386-unknown-unknown -mattr=+avx10.2-256 | FileCheck %s --check-prefix=X86 | ||
|
||
define i1 @hoeq(half %x, half %y) { | ||
; X64-LABEL: hoeq: | ||
; X64: # %bb.0: | ||
; X64-NEXT: vucomxsh %xmm1, %xmm0 | ||
; X64-NEXT: sete %al | ||
; X64-NEXT: retq | ||
; | ||
; X86-LABEL: hoeq: | ||
; X86: # %bb.0: | ||
; X86-NEXT: vmovsh {{.*#+}} xmm0 = mem[0],zero,zero,zero,zero,zero,zero,zero | ||
; X86-NEXT: vucomxsh {{[0-9]+}}(%esp), %xmm0 | ||
; X86-NEXT: sete %al | ||
; X86-NEXT: retl | ||
%1 = fcmp oeq half %x, %y | ||
ret i1 %1 | ||
} | ||
|
||
define i1 @hune(half %x, half %y) { | ||
; X64-LABEL: hune: | ||
; X64: # %bb.0: | ||
; X64-NEXT: vucomxsh %xmm1, %xmm0 | ||
; X64-NEXT: setne %al | ||
; X64-NEXT: retq | ||
; | ||
; X86-LABEL: hune: | ||
; X86: # %bb.0: | ||
; X86-NEXT: vmovsh {{.*#+}} xmm0 = mem[0],zero,zero,zero,zero,zero,zero,zero | ||
; X86-NEXT: vucomxsh {{[0-9]+}}(%esp), %xmm0 | ||
; X86-NEXT: setne %al | ||
; X86-NEXT: retl | ||
%1 = fcmp une half %x, %y | ||
ret i1 %1 | ||
} | ||
|
||
define i1 @hoeq_mem(ptr %xp, ptr %yp) { | ||
; X64-LABEL: hoeq_mem: | ||
; X64: # %bb.0: | ||
; X64-NEXT: vmovsh {{.*#+}} xmm0 = mem[0],zero,zero,zero,zero,zero,zero,zero | ||
; X64-NEXT: vucomxsh (%rsi), %xmm0 | ||
; X64-NEXT: sete %al | ||
; X64-NEXT: retq | ||
; | ||
; X86-LABEL: hoeq_mem: | ||
; X86: # %bb.0: | ||
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax | ||
; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx | ||
; X86-NEXT: vmovsh {{.*#+}} xmm0 = mem[0],zero,zero,zero,zero,zero,zero,zero | ||
; X86-NEXT: vucomxsh (%eax), %xmm0 | ||
; X86-NEXT: sete %al | ||
; X86-NEXT: retl | ||
%x = load half, ptr %xp | ||
%y = load half, ptr %yp | ||
%1 = fcmp oeq half %x, %y | ||
ret i1 %1 | ||
} | ||
|
||
define i1 @hune_mem(ptr %xp, ptr %yp) { | ||
; X64-LABEL: hune_mem: | ||
; X64: # %bb.0: | ||
; X64-NEXT: vmovsh {{.*#+}} xmm0 = mem[0],zero,zero,zero,zero,zero,zero,zero | ||
; X64-NEXT: vucomxsh (%rsi), %xmm0 | ||
; X64-NEXT: setne %al | ||
; X64-NEXT: retq | ||
; | ||
; X86-LABEL: hune_mem: | ||
; X86: # %bb.0: | ||
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax | ||
; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx | ||
; X86-NEXT: vmovsh {{.*#+}} xmm0 = mem[0],zero,zero,zero,zero,zero,zero,zero | ||
; X86-NEXT: vucomxsh (%eax), %xmm0 | ||
; X86-NEXT: setne %al | ||
; X86-NEXT: retl | ||
%x = load half, ptr %xp | ||
%y = load half, ptr %yp | ||
%1 = fcmp une half %x, %y | ||
ret i1 %1 | ||
} | ||
|
||
define i1 @foeq(float %x, float %y) { | ||
; X64-LABEL: foeq: | ||
; X64: # %bb.0: | ||
; X64-NEXT: vucomxss %xmm1, %xmm0 | ||
; X64-NEXT: sete %al | ||
; X64-NEXT: retq | ||
; | ||
; X86-LABEL: foeq: | ||
; X86: # %bb.0: | ||
; X86-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero | ||
; X86-NEXT: vucomxss {{[0-9]+}}(%esp), %xmm0 | ||
; X86-NEXT: sete %al | ||
; X86-NEXT: retl | ||
%1 = fcmp oeq float %x, %y | ||
ret i1 %1 | ||
} | ||
|
||
define i1 @fune(float %x, float %y) { | ||
; X64-LABEL: fune: | ||
; X64: # %bb.0: | ||
; X64-NEXT: vucomxss %xmm1, %xmm0 | ||
; X64-NEXT: setne %al | ||
; X64-NEXT: retq | ||
; | ||
; X86-LABEL: fune: | ||
; X86: # %bb.0: | ||
; X86-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero | ||
; X86-NEXT: vucomxss {{[0-9]+}}(%esp), %xmm0 | ||
; X86-NEXT: setne %al | ||
; X86-NEXT: retl | ||
%1 = fcmp une float %x, %y | ||
ret i1 %1 | ||
} | ||
|
||
define i1 @foeq_mem(ptr %xp, ptr %yp) { | ||
; X64-LABEL: foeq_mem: | ||
; X64: # %bb.0: | ||
; X64-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero | ||
; X64-NEXT: vucomxss (%rsi), %xmm0 | ||
; X64-NEXT: sete %al | ||
; X64-NEXT: retq | ||
; | ||
; X86-LABEL: foeq_mem: | ||
; X86: # %bb.0: | ||
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax | ||
; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx | ||
; X86-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero | ||
; X86-NEXT: vucomxss (%eax), %xmm0 | ||
; X86-NEXT: sete %al | ||
; X86-NEXT: retl | ||
%x = load float, ptr %xp | ||
%y = load float, ptr %yp | ||
%1 = fcmp oeq float %x, %y | ||
ret i1 %1 | ||
} | ||
|
||
define i1 @fune_mem(ptr %xp, ptr %yp) { | ||
; X64-LABEL: fune_mem: | ||
; X64: # %bb.0: | ||
; X64-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero | ||
; X64-NEXT: vucomxss (%rsi), %xmm0 | ||
; X64-NEXT: setne %al | ||
; X64-NEXT: retq | ||
; | ||
; X86-LABEL: fune_mem: | ||
; X86: # %bb.0: | ||
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax | ||
; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx | ||
; X86-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero | ||
; X86-NEXT: vucomxss (%eax), %xmm0 | ||
; X86-NEXT: setne %al | ||
; X86-NEXT: retl | ||
%x = load float, ptr %xp | ||
%y = load float, ptr %yp | ||
%1 = fcmp une float %x, %y | ||
ret i1 %1 | ||
} | ||
|
||
define i1 @doeq(double %x, double %y) { | ||
; X64-LABEL: doeq: | ||
; X64: # %bb.0: | ||
; X64-NEXT: vucomxsd %xmm1, %xmm0 | ||
; X64-NEXT: sete %al | ||
; X64-NEXT: retq | ||
; | ||
; X86-LABEL: doeq: | ||
; X86: # %bb.0: | ||
; X86-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero | ||
; X86-NEXT: vucomxsd {{[0-9]+}}(%esp), %xmm0 | ||
; X86-NEXT: sete %al | ||
; X86-NEXT: retl | ||
%1 = fcmp oeq double %x, %y | ||
ret i1 %1 | ||
} | ||
|
||
define i1 @dune(double %x, double %y) { | ||
; X64-LABEL: dune: | ||
; X64: # %bb.0: | ||
; X64-NEXT: vucomxsd %xmm1, %xmm0 | ||
; X64-NEXT: setne %al | ||
; X64-NEXT: retq | ||
; | ||
; X86-LABEL: dune: | ||
; X86: # %bb.0: | ||
; X86-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero | ||
; X86-NEXT: vucomxsd {{[0-9]+}}(%esp), %xmm0 | ||
; X86-NEXT: setne %al | ||
; X86-NEXT: retl | ||
%1 = fcmp une double %x, %y | ||
ret i1 %1 | ||
} | ||
|
||
define i1 @doeq_mem(ptr %xp, ptr %yp) { | ||
; X64-LABEL: doeq_mem: | ||
; X64: # %bb.0: | ||
; X64-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero | ||
; X64-NEXT: vucomxsd (%rsi), %xmm0 | ||
; X64-NEXT: sete %al | ||
; X64-NEXT: retq | ||
; | ||
; X86-LABEL: doeq_mem: | ||
; X86: # %bb.0: | ||
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax | ||
; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx | ||
; X86-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero | ||
; X86-NEXT: vucomxsd (%eax), %xmm0 | ||
; X86-NEXT: sete %al | ||
; X86-NEXT: retl | ||
%x = load double, ptr %xp | ||
%y = load double, ptr %yp | ||
%1 = fcmp oeq double %x, %y | ||
ret i1 %1 | ||
} | ||
|
||
define i1 @dune_mem(ptr %xp, ptr %yp) { | ||
; X64-LABEL: dune_mem: | ||
; X64: # %bb.0: | ||
; X64-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero | ||
; X64-NEXT: vucomxsd (%rsi), %xmm0 | ||
; X64-NEXT: setne %al | ||
; X64-NEXT: retq | ||
; | ||
; X86-LABEL: dune_mem: | ||
; X86: # %bb.0: | ||
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax | ||
; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx | ||
; X86-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero | ||
; X86-NEXT: vucomxsd (%eax), %xmm0 | ||
; X86-NEXT: setne %al | ||
; X86-NEXT: retl | ||
%x = load double, ptr %xp | ||
%y = load double, ptr %yp | ||
%1 = fcmp une double %x, %y | ||
ret i1 %1 | ||
} |
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
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.
Why don't combine them to the loop? You can move them to line 2445.
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 can do that. Although
setGroup(MVT::f16);
on 2286 line above has better proximity fore related code.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.
The code is in the scope of
hasFP16
. We prefer to organizing them in feature bulk rather than mixing them together.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.
This code movement result in 3 regressions.
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 don't see how it results in regressions. Did you remove these 2 Expand?
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.
Here is link on infra.
https://github.com/llvm/llvm-project/pull/113695/files
https://buildkite.com/llvm-project/github-pull-requests/builds/113138#0192c4a7-5933-4d41-b189-f83fdfe10fd9
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 meant this:
Notice it's under these code, so it should not affect any existing tests.
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.
#113695
#113905, 2 commits on this very branch
I tried out 4 different ways, except current change i get regression for all moves.
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.
See 2c9b981
I don't see any problem on my side.
Maybe you was misled. The diff above was to demonstrate the change in function
X86TargetLowering
, so I omitted the change inLowerSETCC
. I'm surprised you didn't explore along this way.