[llvm] 81279bf - [X86] Fix missing check of rotate <-> shift equivilence (Issue 108722)
Noah Goldstein via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 15 16:15:20 PDT 2024
Author: Noah Goldstein
Date: 2024-09-15T16:15:05-07:00
New Revision: 81279bf97f187eee0446af00d8ae9ec32a22e878
URL: https://github.com/llvm/llvm-project/commit/81279bf97f187eee0446af00d8ae9ec32a22e878
DIFF: https://github.com/llvm/llvm-project/commit/81279bf97f187eee0446af00d8ae9ec32a22e878.diff
LOG: [X86] Fix missing check of rotate <-> shift equivilence (Issue 108722)
Previous code was checking that rotate and shift where equivilent when
transforming shift -> rotate but not the other way around.
Closes #108767
Added:
Modified:
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/cmp-shiftX-maskX.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 053b2354f6aeb6..d73c49124315a9 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -3489,7 +3489,7 @@ unsigned X86TargetLowering::preferedOpcodeForCmpEqPiecesOfOperand(
// We prefer rotate for vectors of if we won't get a zext mask with SRL
// (PreferRotate will be set in the latter case).
- if (PreferRotate || VT.isVector())
+ if (PreferRotate || !MayTransformRotate || VT.isVector())
return ShiftOpc;
// Non-vector type and we have a zext mask with SRL.
diff --git a/llvm/test/CodeGen/X86/cmp-shiftX-maskX.ll b/llvm/test/CodeGen/X86/cmp-shiftX-maskX.ll
index 799b5417857575..227de9ad0ab690 100644
--- a/llvm/test/CodeGen/X86/cmp-shiftX-maskX.ll
+++ b/llvm/test/CodeGen/X86/cmp-shiftX-maskX.ll
@@ -997,8 +997,8 @@ define i1 @shr_to_rotate_eq_i32_s5(i32 %x) {
define i32 @issue108722(i32 %0) {
; CHECK-NOBMI-LABEL: issue108722:
; CHECK-NOBMI: # %bb.0:
-; CHECK-NOBMI-NEXT: movzbl %dil, %ecx
-; CHECK-NOBMI-NEXT: shrl $24, %edi
+; CHECK-NOBMI-NEXT: movl %edi, %ecx
+; CHECK-NOBMI-NEXT: roll $24, %ecx
; CHECK-NOBMI-NEXT: xorl %eax, %eax
; CHECK-NOBMI-NEXT: cmpl %edi, %ecx
; CHECK-NOBMI-NEXT: sete %al
More information about the llvm-commits
mailing list