-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[LegalizeTypes][X86][PowerPC] Use shift by 1 instead of adding a value to itself to double. #86857
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 |
---|---|---|
|
@@ -165,12 +165,12 @@ define <2 x i64> @testDoubleword(<2 x i64> %a, i64 %b, i64 %idx) { | |
; | ||
; CHECK-32-LABEL: testDoubleword: | ||
; CHECK-32: # %bb.0: # %entry | ||
; CHECK-32-NEXT: add 5, 6, 6 | ||
; CHECK-32-NEXT: addi 7, 1, -32 | ||
; CHECK-32-NEXT: slwi 5, 6, 1 | ||
; CHECK-32-NEXT: rlwinm 6, 6, 3, 28, 28 | ||
; CHECK-32-NEXT: stxv 34, -32(1) | ||
; CHECK-32-NEXT: rlwinm 6, 5, 2, 28, 29 | ||
; CHECK-32-NEXT: stwx 3, 7, 6 | ||
; CHECK-32-NEXT: addi 3, 5, 1 | ||
; CHECK-32-NEXT: ori 3, 5, 1 | ||
; CHECK-32-NEXT: addi 5, 1, -16 | ||
; CHECK-32-NEXT: lxv 0, -32(1) | ||
; CHECK-32-NEXT: rlwinm 3, 3, 2, 28, 29 | ||
|
@@ -187,10 +187,11 @@ define <2 x i64> @testDoubleword(<2 x i64> %a, i64 %b, i64 %idx) { | |
; | ||
; CHECK-32-P10-LABEL: testDoubleword: | ||
; CHECK-32-P10: # %bb.0: # %entry | ||
; CHECK-32-P10-NEXT: add 5, 6, 6 | ||
; CHECK-32-P10-NEXT: slwi 6, 5, 2 | ||
; CHECK-32-P10-NEXT: slwi 5, 6, 1 | ||
; CHECK-32-P10-NEXT: slwi 6, 6, 3 | ||
; CHECK-32-P10-NEXT: vinswlx 2, 6, 3 | ||
; CHECK-32-P10-NEXT: addi 3, 5, 1 | ||
; CHECK-32-P10-NEXT: li 3, 1 | ||
; CHECK-32-P10-NEXT: rlwimi 3, 5, 0, 0, 30 | ||
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 exposes an combine opportunity on PPC.
should be just:
We will handle this later. 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. li 3, 1 should be a zero cycle operation on P10 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. we do it in more generically.
if 2^(31-n) >val we can convert to
or
|
||
; CHECK-32-P10-NEXT: slwi 3, 3, 2 | ||
; CHECK-32-P10-NEXT: vinswlx 2, 3, 4 | ||
; CHECK-32-P10-NEXT: blr | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1019,7 +1019,7 @@ define <2 x i64> @arg_i64_v2i64(<2 x i64> %v, i64 %x, i32 %y) nounwind { | |
; X86AVX2-NEXT: movl %edx, (%esp,%esi,4) | ||
; X86AVX2-NEXT: vmovaps (%esp), %xmm0 | ||
; X86AVX2-NEXT: vmovaps %xmm0, {{[0-9]+}}(%esp) | ||
; X86AVX2-NEXT: incl %ecx | ||
; X86AVX2-NEXT: orl $1, %ecx | ||
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. Why OR is better than INC? I see they have the same TP/ports but OR has one more byte longer and Lat seems longer too in some case? 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 guess we're missing addlike matching in the inc patterns? 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. CC @goldsteinn who was working on something similar for #83691 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. NB: that patch doesn't fix the issue. 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. Sadly my or_is_add patch did not work either. This is the final DAG
You can see there are 2 uses of t42. Both of those are nodes that a |
||
; X86AVX2-NEXT: andl $3, %ecx | ||
; X86AVX2-NEXT: movl %eax, 16(%esp,%ecx,4) | ||
; X86AVX2-NEXT: vmovaps {{[0-9]+}}(%esp), %xmm0 | ||
|
@@ -1369,7 +1369,7 @@ define <2 x i64> @load_i64_v2i64(<2 x i64> %v, ptr %p, i32 %y) nounwind { | |
; X86AVX2-NEXT: movl %edx, (%esp,%esi,4) | ||
; X86AVX2-NEXT: vmovaps (%esp), %xmm0 | ||
; X86AVX2-NEXT: vmovaps %xmm0, {{[0-9]+}}(%esp) | ||
; X86AVX2-NEXT: incl %eax | ||
; X86AVX2-NEXT: orl $1, %eax | ||
; X86AVX2-NEXT: andl $3, %eax | ||
; X86AVX2-NEXT: movl %ecx, 16(%esp,%eax,4) | ||
; X86AVX2-NEXT: vmovaps {{[0-9]+}}(%esp), %xmm0 | ||
|
@@ -1754,7 +1754,7 @@ define <4 x i64> @arg_i64_v4i64(<4 x i64> %v, i64 %x, i32 %y) nounwind { | |
; X86AVX2-NEXT: movl %edx, (%esp,%esi,4) | ||
; X86AVX2-NEXT: vmovaps (%esp), %ymm0 | ||
; X86AVX2-NEXT: vmovaps %ymm0, {{[0-9]+}}(%esp) | ||
; X86AVX2-NEXT: incl %ecx | ||
; X86AVX2-NEXT: orl $1, %ecx | ||
; X86AVX2-NEXT: andl $7, %ecx | ||
; X86AVX2-NEXT: movl %eax, 32(%esp,%ecx,4) | ||
; X86AVX2-NEXT: vmovaps {{[0-9]+}}(%esp), %ymm0 | ||
|
@@ -2137,7 +2137,7 @@ define <4 x i64> @load_i64_v4i64(<4 x i64> %v, ptr %p, i32 %y) nounwind { | |
; X86AVX2-NEXT: movl %edx, (%esp,%esi,4) | ||
; X86AVX2-NEXT: vmovaps (%esp), %ymm0 | ||
; X86AVX2-NEXT: vmovaps %ymm0, {{[0-9]+}}(%esp) | ||
; X86AVX2-NEXT: incl %eax | ||
; X86AVX2-NEXT: orl $1, %eax | ||
; X86AVX2-NEXT: andl $7, %eax | ||
; X86AVX2-NEXT: movl %ecx, 32(%esp,%eax,4) | ||
; X86AVX2-NEXT: vmovaps {{[0-9]+}}(%esp), %ymm0 | ||
|
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 shows the advantage, after changing add to shift, on ppc,