[llvm-branch-commits] [llvm] release/19.x: [X86] Fix missing check of rotate <-> shift equivilence (Issue 108722) (PR #108783)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Sun Sep 15 16:46:03 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-x86
Author: None (llvmbot)
<details>
<summary>Changes</summary>
Backport 1c378d2b145578948942512f9d6985e37659d013 81279bf97f187eee0446af00d8ae9ec32a22e878
Requested by: @<!-- -->goldsteinn
---
Full diff: https://github.com/llvm/llvm-project/pull/108783.diff
2 Files Affected:
- (modified) llvm/lib/Target/X86/X86ISelLowering.cpp (+1-1)
- (modified) llvm/test/CodeGen/X86/cmp-shiftX-maskX.ll (+24)
``````````diff
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 5a9d679d7002cb..45989bcd07d37e 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -3415,7 +3415,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 67070b989786db..227de9ad0ab690 100644
--- a/llvm/test/CodeGen/X86/cmp-shiftX-maskX.ll
+++ b/llvm/test/CodeGen/X86/cmp-shiftX-maskX.ll
@@ -994,6 +994,30 @@ define i1 @shr_to_rotate_eq_i32_s5(i32 %x) {
ret i1 %r
}
+define i32 @issue108722(i32 %0) {
+; CHECK-NOBMI-LABEL: issue108722:
+; CHECK-NOBMI: # %bb.0:
+; 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
+; CHECK-NOBMI-NEXT: retq
+;
+; CHECK-BMI2-LABEL: issue108722:
+; CHECK-BMI2: # %bb.0:
+; CHECK-BMI2-NEXT: rorxl $8, %edi, %ecx
+; CHECK-BMI2-NEXT: xorl %eax, %eax
+; CHECK-BMI2-NEXT: cmpl %edi, %ecx
+; CHECK-BMI2-NEXT: sete %al
+; CHECK-BMI2-NEXT: retq
+ %2 = tail call i32 @llvm.fshl.i32(i32 %0, i32 %0, i32 24)
+ %3 = icmp eq i32 %2, %0
+ %4 = zext i1 %3 to i32
+ ret i32 %4
+}
+
+
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
; CHECK-AVX: {{.*}}
; CHECK-NOBMI-SSE2: {{.*}}
``````````
</details>
https://github.com/llvm/llvm-project/pull/108783
More information about the llvm-branch-commits
mailing list