-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[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 8 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::f16, 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); | ||
|
@@ -24073,6 +24079,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.
Move this under FP16 code. We need to override
f16
with this 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.
you mean only FP16 or Complete SetCondCodeAction for f16, f32 and f64?
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.
All of them. See the line number of previous diff.
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.
#113905 I tried this. Moved SETOEQ and SETUNE group after avx10_2 & softfloat feature. it did not work.