// conditions 1) one-use, 2) does not produce poison, and 3) has all but one
// guaranteed-non-poison operands then push the freeze through to the one
// operand that is not guaranteed non-poison.
- if (!DAG.canCreateUndefOrPoison(N0, /*PoisonOnly*/ false) &&
+ if (!DAG.canCreateUndefOrPoison(N0, /*PoisonOnly*/ false,
+ /*ConsiderFlags*/ true) &&
N0->getNumValues() == 1 && N0->hasOneUse()) {
SDValue MaybePoisonOperand;
for (SDValue Op : N0->ops()) {
}
if (MaybePoisonOperand) {
// Recreate the node with the frozen maybe-poison operand.
+ // TODO: Disable ConsiderFlags and just strip poison generating flags?
// TODO: Drop the isOnlyUserOf constraint and replace all users of
// MaybePoisonOperand with FrozenMaybePoisonOperand
// to match pushFreezeToPreventPoisonFromPropagating behavior.
; X86-LABEL: freeze_add:
; X86: # %bb.0:
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
-; X86-NEXT: incl %eax
-; X86-NEXT: incl %eax
+; X86-NEXT: addl $2, %eax
; X86-NEXT: retl
;
; X64-LABEL: freeze_add:
; X64: # %bb.0:
; X64-NEXT: # kill: def $edi killed $edi def $rdi
-; X64-NEXT: leal 1(%rdi), %eax
-; X64-NEXT: incl %eax
+; X64-NEXT: leal 2(%rdi), %eax
; X64-NEXT: retq
%x = add i32 %a0, 1
%y = freeze i32 %x
; X86-LABEL: freeze_add_vec:
; X86: # %bb.0:
; X86-NEXT: paddd {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
-; X86-NEXT: paddd {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
; X86-NEXT: retl
;
; X64-LABEL: freeze_add_vec:
; X64: # %bb.0:
-; X64-NEXT: vpaddd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
-; X64-NEXT: vpaddd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
+; X64-NEXT: vpbroadcastd {{.*#+}} xmm1 = [5,5,5,5]
+; X64-NEXT: vpaddd %xmm1, %xmm0, %xmm0
; X64-NEXT: retq
%x = add <4 x i32> %a0, <i32 1, i32 2, i32 3, i32 4>
%y = freeze <4 x i32> %x
; X86-LABEL: freeze_sub:
; X86: # %bb.0:
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
-; X86-NEXT: decl %eax
-; X86-NEXT: decl %eax
+; X86-NEXT: addl $-2, %eax
; X86-NEXT: retl
;
; X64-LABEL: freeze_sub:
; X64: # %bb.0:
; X64-NEXT: # kill: def $edi killed $edi def $rdi
-; X64-NEXT: leal -1(%rdi), %eax
-; X64-NEXT: decl %eax
+; X64-NEXT: leal -2(%rdi), %eax
; X64-NEXT: retq
%x = sub i32 %a0, 1
%y = freeze i32 %x
; X86-LABEL: freeze_sub_nuw:
; X86: # %bb.0:
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
-; X86-NEXT: decl %eax
-; X86-NEXT: decl %eax
+; X86-NEXT: addl $-2, %eax
; X86-NEXT: retl
;
; X64-LABEL: freeze_sub_nuw:
; X64: # %bb.0:
; X64-NEXT: # kill: def $edi killed $edi def $rdi
-; X64-NEXT: leal -1(%rdi), %eax
-; X64-NEXT: decl %eax
+; X64-NEXT: leal -2(%rdi), %eax
; X64-NEXT: retq
%x = sub nuw i32 %a0, 1
%y = freeze i32 %x
; X86-LABEL: freeze_sub_vec:
; X86: # %bb.0:
; X86-NEXT: psubd {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
-; X86-NEXT: psubd {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
; X86-NEXT: retl
;
; X64-LABEL: freeze_sub_vec:
; X64: # %bb.0:
-; X64-NEXT: vpsubd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
-; X64-NEXT: vpsubd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
+; X64-NEXT: vpbroadcastd {{.*#+}} xmm1 = [5,5,5,5]
+; X64-NEXT: vpsubd %xmm1, %xmm0, %xmm0
; X64-NEXT: retq
%x = sub <4 x i32> %a0, <i32 1, i32 2, i32 3, i32 4>
%y = freeze <4 x i32> %x
; X86-LABEL: freeze_mul:
; X86: # %bb.0:
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
-; X86-NEXT: addl %eax, %eax
-; X86-NEXT: addl %eax, %eax
+; X86-NEXT: shll $2, %eax
; X86-NEXT: retl
;
; X64-LABEL: freeze_mul:
; X64: # %bb.0:
; X64-NEXT: # kill: def $edi killed $edi def $rdi
-; X64-NEXT: leal (%rdi,%rdi), %eax
-; X64-NEXT: addl %eax, %eax
+; X64-NEXT: leal (,%rdi,4), %eax
; X64-NEXT: retq
%x = mul i32 %a0, 2
%y = freeze i32 %x
; X86-LABEL: freeze_mul_vec:
; X86: # %bb.0:
; X86-NEXT: pmullw {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
-; X86-NEXT: pmullw {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
; X86-NEXT: retl
;
; X64-LABEL: freeze_mul_vec:
; X64: # %bb.0:
; X64-NEXT: vpmullw {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
-; X64-NEXT: vpmullw {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
; X64-NEXT: retq
%x = mul <8 x i16> %a0, <i16 1, i16 2, i16 3, i16 4, i16 4, i16 3, i16 2, i16 1>
%y = freeze <8 x i16> %x