Skip to content

Commit 81279bf

Browse files
committed
[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
1 parent 1c378d2 commit 81279bf

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3489,7 +3489,7 @@ unsigned X86TargetLowering::preferedOpcodeForCmpEqPiecesOfOperand(
34893489

34903490
// We prefer rotate for vectors of if we won't get a zext mask with SRL
34913491
// (PreferRotate will be set in the latter case).
3492-
if (PreferRotate || VT.isVector())
3492+
if (PreferRotate || !MayTransformRotate || VT.isVector())
34933493
return ShiftOpc;
34943494

34953495
// Non-vector type and we have a zext mask with SRL.

llvm/test/CodeGen/X86/cmp-shiftX-maskX.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -997,8 +997,8 @@ define i1 @shr_to_rotate_eq_i32_s5(i32 %x) {
997997
define i32 @issue108722(i32 %0) {
998998
; CHECK-NOBMI-LABEL: issue108722:
999999
; CHECK-NOBMI: # %bb.0:
1000-
; CHECK-NOBMI-NEXT: movzbl %dil, %ecx
1001-
; CHECK-NOBMI-NEXT: shrl $24, %edi
1000+
; CHECK-NOBMI-NEXT: movl %edi, %ecx
1001+
; CHECK-NOBMI-NEXT: roll $24, %ecx
10021002
; CHECK-NOBMI-NEXT: xorl %eax, %eax
10031003
; CHECK-NOBMI-NEXT: cmpl %edi, %ecx
10041004
; CHECK-NOBMI-NEXT: sete %al

0 commit comments

Comments
 (0)