[PATCH] D144985: [X86] Make `(shift X (xor/sub N-1, Y))` -> `(shift X, (not Y))` check for one use.
Noah Goldstein via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 28 14:16:50 PST 2023
goldstein.w.n updated this revision to Diff 501294.
goldstein.w.n added a comment.
Rebase
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D144985/new/
https://reviews.llvm.org/D144985
Files:
llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
llvm/test/CodeGen/X86/pr61038.ll
Index: llvm/test/CodeGen/X86/pr61038.ll
===================================================================
--- llvm/test/CodeGen/X86/pr61038.ll
+++ llvm/test/CodeGen/X86/pr61038.ll
@@ -9,28 +9,24 @@
; CHECK-BMI2: # %bb.0: # %entry
; CHECK-BMI2-NEXT: tzcntl %eax, %eax
; CHECK-BMI2-NEXT: movabsq $8589934591, %rcx # imm = 0x1FFFFFFFF
-; CHECK-BMI2-NEXT: movq $-1, %rdx
+; CHECK-BMI2-NEXT: movq %rcx, %rdx
; CHECK-BMI2-NEXT: btcq %rax, %rdx
-; CHECK-BMI2-NEXT: shrxq %rdx, %rcx, %rdx
-; CHECK-BMI2-NEXT: btcq %rax, %rcx
; CHECK-BMI2-NEXT: xorl %eax, %eax
-; CHECK-BMI2-NEXT: cmpq $64, %rcx
-; CHECK-BMI2-NEXT: cmovael %eax, %edx
-; CHECK-BMI2-NEXT: movl %edx, (%rdi)
+; CHECK-BMI2-NEXT: cmpq $64, %rdx
+; CHECK-BMI2-NEXT: shrxq %rdx, %rcx, %rcx
+; CHECK-BMI2-NEXT: cmovael %eax, %ecx
+; CHECK-BMI2-NEXT: movl %ecx, (%rdi)
; CHECK-BMI2-NEXT: retq
;
; CHECK-BMI-LABEL: test_61038:
; CHECK-BMI: # %bb.0: # %entry
; CHECK-BMI-NEXT: tzcntl %eax, %eax
; CHECK-BMI-NEXT: movabsq $8589934591, %rdx # imm = 0x1FFFFFFFF
-; CHECK-BMI-NEXT: movq %rdx, %rsi
-; CHECK-BMI-NEXT: btcq %rax, %rsi
-; CHECK-BMI-NEXT: movq $-1, %rcx
+; CHECK-BMI-NEXT: movq %rdx, %rcx
; CHECK-BMI-NEXT: btcq %rax, %rcx
-; CHECK-BMI-NEXT: # kill: def $cl killed $cl killed $rcx
; CHECK-BMI-NEXT: shrq %cl, %rdx
; CHECK-BMI-NEXT: xorl %eax, %eax
-; CHECK-BMI-NEXT: cmpq $64, %rsi
+; CHECK-BMI-NEXT: cmpq $64, %rcx
; CHECK-BMI-NEXT: cmovael %eax, %edx
; CHECK-BMI-NEXT: movl %edx, (%rdi)
; CHECK-BMI-NEXT: retq
Index: llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
===================================================================
--- llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
+++ llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
@@ -4007,7 +4007,7 @@
if (Add1C && Add1C->getAPIntValue().urem(Size) == 0) {
NewShiftAmt = Add0;
- } else if (ShiftAmt->getOpcode() != ISD::ADD &&
+ } else if (ShiftAmt->getOpcode() != ISD::ADD && ShiftAmt.hasOneUse() &&
((Add0C && Add0C->getAPIntValue().urem(Size) == Size - 1) ||
(Add1C && Add1C->getAPIntValue().urem(Size) == Size - 1))) {
// If we are doing a NOT on just the lower bits with (Size*N-1) -/^ X
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144985.501294.patch
Type: text/x-patch
Size: 2269 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230228/f6c33db8/attachment.bin>
More information about the llvm-commits
mailing list