forked from OSchip/llvm-project
[X86] Fold cmpeq/ne(or(X,Y),X) --> cmpeq/ne(and(~X,Y),0) on non-BMI targets (PR44136)
Followup to D100177, enable the fold for non-BMI targets as well.
This commit is contained in:
parent
b7578f9d5a
commit
d8bc4de3cf
|
@ -48165,7 +48165,7 @@ static SDValue combineSetCC(SDNode *N, SelectionDAG &DAG,
|
|||
|
||||
// cmpeq(or(X,Y),X) --> cmpeq(and(~X,Y),0)
|
||||
// cmpne(or(X,Y),X) --> cmpne(and(~X,Y),0)
|
||||
if (OpVT.isScalarInteger() && Subtarget.hasBMI()) {
|
||||
if (OpVT.isScalarInteger()) {
|
||||
auto MatchOrCmpEq = [&](SDValue N0, SDValue N1) {
|
||||
if (N0.getOpcode() == ISD::OR && N0->hasOneUse()) {
|
||||
if (N0.getOperand(0) == N1)
|
||||
|
|
|
@ -155,13 +155,10 @@ B:
|
|||
define i32 @test10(i64 %b, i64 %c, i1 %d) {
|
||||
; ALL-LABEL: test10:
|
||||
; ALL: ## %bb.0:
|
||||
; ALL-NEXT: movl %edx, %eax
|
||||
; ALL-NEXT: andb $1, %al
|
||||
; ALL-NEXT: cmpq %rsi, %rdi
|
||||
; ALL-NEXT: sete %cl
|
||||
; ALL-NEXT: orb %dl, %cl
|
||||
; ALL-NEXT: andb $1, %cl
|
||||
; ALL-NEXT: cmpb %cl, %al
|
||||
; ALL-NEXT: sete %al
|
||||
; ALL-NEXT: notb %dl
|
||||
; ALL-NEXT: testb %al, %dl
|
||||
; ALL-NEXT: je LBB8_1
|
||||
; ALL-NEXT: ## %bb.2: ## %if.end.i
|
||||
; ALL-NEXT: movl $6, %eax
|
||||
|
|
|
@ -33,8 +33,7 @@ define i1 @foo_pgso(i32 %i) !prof !14 {
|
|||
define zeroext i1 @g(i32 %x) optsize {
|
||||
; CHECK-LABEL: g:
|
||||
; CHECK: # %bb.0:
|
||||
; CHECK-NEXT: orl $1, %edi
|
||||
; CHECK-NEXT: cmpl $1, %edi
|
||||
; CHECK-NEXT: testl $-2, %edi
|
||||
; CHECK-NEXT: sete %al
|
||||
; CHECK-NEXT: retq
|
||||
%t0 = or i32 %x, 1
|
||||
|
|
|
@ -37,9 +37,7 @@ define i8* @SyFgets(i8* %line, i64 %length, i64 %fid) {
|
|||
; CHECK-NEXT: .cfi_offset %r14, -32
|
||||
; CHECK-NEXT: .cfi_offset %r15, -24
|
||||
; CHECK-NEXT: .cfi_offset %rbp, -16
|
||||
; CHECK-NEXT: movq %rdx, %rax
|
||||
; CHECK-NEXT: orq $2, %rax
|
||||
; CHECK-NEXT: cmpq $2, %rax
|
||||
; CHECK-NEXT: testq $-3, %rdx
|
||||
; CHECK-NEXT: jne LBB0_4
|
||||
; CHECK-NEXT: ## %bb.1: ## %if.end
|
||||
; CHECK-NEXT: xorl %eax, %eax
|
||||
|
|
|
@ -612,8 +612,8 @@ define i1 @and_icmps_const_1bit_diff_common_op(i32 %x, i32 %y) {
|
|||
define i1 @or_cmp_eq_i64(i64 %x, i64 %y) {
|
||||
; NOBMI-LABEL: or_cmp_eq_i64:
|
||||
; NOBMI: # %bb.0:
|
||||
; NOBMI-NEXT: orq %rdi, %rsi
|
||||
; NOBMI-NEXT: cmpq %rdi, %rsi
|
||||
; NOBMI-NEXT: notq %rdi
|
||||
; NOBMI-NEXT: testq %rsi, %rdi
|
||||
; NOBMI-NEXT: sete %al
|
||||
; NOBMI-NEXT: retq
|
||||
;
|
||||
|
@ -630,8 +630,8 @@ define i1 @or_cmp_eq_i64(i64 %x, i64 %y) {
|
|||
define i1 @or_cmp_ne_i32(i32 %x, i32 %y) {
|
||||
; NOBMI-LABEL: or_cmp_ne_i32:
|
||||
; NOBMI: # %bb.0:
|
||||
; NOBMI-NEXT: orl %esi, %edi
|
||||
; NOBMI-NEXT: cmpl %esi, %edi
|
||||
; NOBMI-NEXT: notl %esi
|
||||
; NOBMI-NEXT: testl %edi, %esi
|
||||
; NOBMI-NEXT: setne %al
|
||||
; NOBMI-NEXT: retq
|
||||
;
|
||||
|
@ -646,38 +646,24 @@ define i1 @or_cmp_ne_i32(i32 %x, i32 %y) {
|
|||
}
|
||||
|
||||
define i1 @or_cmp_eq_i16(i16 zeroext %x, i16 zeroext %y) {
|
||||
; NOBMI-LABEL: or_cmp_eq_i16:
|
||||
; NOBMI: # %bb.0:
|
||||
; NOBMI-NEXT: orl %edi, %esi
|
||||
; NOBMI-NEXT: cmpw %si, %di
|
||||
; NOBMI-NEXT: sete %al
|
||||
; NOBMI-NEXT: retq
|
||||
;
|
||||
; BMI-LABEL: or_cmp_eq_i16:
|
||||
; BMI: # %bb.0:
|
||||
; BMI-NEXT: notl %edi
|
||||
; BMI-NEXT: testw %si, %di
|
||||
; BMI-NEXT: sete %al
|
||||
; BMI-NEXT: retq
|
||||
; CHECK-LABEL: or_cmp_eq_i16:
|
||||
; CHECK: # %bb.0:
|
||||
; CHECK-NEXT: notl %edi
|
||||
; CHECK-NEXT: testw %si, %di
|
||||
; CHECK-NEXT: sete %al
|
||||
; CHECK-NEXT: retq
|
||||
%o = or i16 %x, %y
|
||||
%c = icmp eq i16 %x, %o
|
||||
ret i1 %c
|
||||
}
|
||||
|
||||
define i1 @or_cmp_ne_i8(i8 zeroext %x, i8 zeroext %y) {
|
||||
; NOBMI-LABEL: or_cmp_ne_i8:
|
||||
; NOBMI: # %bb.0:
|
||||
; NOBMI-NEXT: orl %esi, %edi
|
||||
; NOBMI-NEXT: cmpb %dil, %sil
|
||||
; NOBMI-NEXT: setne %al
|
||||
; NOBMI-NEXT: retq
|
||||
;
|
||||
; BMI-LABEL: or_cmp_ne_i8:
|
||||
; BMI: # %bb.0:
|
||||
; BMI-NEXT: notb %sil
|
||||
; BMI-NEXT: testb %dil, %sil
|
||||
; BMI-NEXT: setne %al
|
||||
; BMI-NEXT: retq
|
||||
; CHECK-LABEL: or_cmp_ne_i8:
|
||||
; CHECK: # %bb.0:
|
||||
; CHECK-NEXT: notb %sil
|
||||
; CHECK-NEXT: testb %dil, %sil
|
||||
; CHECK-NEXT: setne %al
|
||||
; CHECK-NEXT: retq
|
||||
%o = or i8 %x, %y
|
||||
%c = icmp ne i8 %y, %o
|
||||
ret i1 %c
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
; CHECK-LABEL: test1
|
||||
; CHECK: orl $2
|
||||
; CHECK-NEXT: cmpl $6
|
||||
|
||||
define void @test1(i32 %variable) nounwind {
|
||||
entry:
|
||||
switch i32 %variable, label %if.end [
|
||||
|
@ -21,8 +20,7 @@ if.end:
|
|||
}
|
||||
|
||||
; CHECK-LABEL: test2
|
||||
; CHECK: orl $-2147483648
|
||||
; CHECK-NEXT: cmpl $-2147483648
|
||||
; CHECK: testl $2147483647
|
||||
define void @test2(i32 %variable) nounwind {
|
||||
entry:
|
||||
switch i32 %variable, label %if.end [
|
||||
|
|
Loading…
Reference in New Issue