if (isUndef(Opcode, Ops))
return getUNDEF(VT);
- // Handle the case of two scalars.
+ // Handle binops special cases.
if (NumOps == 2) {
- // TODO: Move foldConstantFPMath here?
+ if (SDValue CFP = foldConstantFPMath(Opcode, DL, VT, Ops[0], Ops[1]))
+ return CFP;
if (auto *C1 = dyn_cast<ConstantSDNode>(Ops[0])) {
if (auto *C2 = dyn_cast<ConstantSDNode>(Ops[1])) {
if (SDValue SV = FoldConstantArithmetic(Opcode, DL, VT, {N1, N2}))
return SV;
- if (SDValue V = foldConstantFPMath(Opcode, DL, VT, N1, N2))
- return V;
-
// Canonicalize an UNDEF to the RHS, even over a constant.
if (N1.isUndef()) {
if (TLI->isCommutativeBinOp(Opcode)) {
define <2 x double> @fadd_undef_op1_constant_vec(<2 x double> %x) {
; ANY-LABEL: fadd_undef_op1_constant_vec:
; ANY: # %bb.0:
-; ANY-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
+; ANY-NEXT: movaps {{.*#+}} xmm0 = [NaN,NaN]
; ANY-NEXT: retq
%r = fadd <2 x double> <double 42.0, double undef>, undef
ret <2 x double> %r
define <2 x double> @fadd_undef_op0_constant_vec(<2 x double> %x) {
; ANY-LABEL: fadd_undef_op0_constant_vec:
; ANY: # %bb.0:
-; ANY-NEXT: movaps {{.*#+}} xmm0 = <u,NaN>
+; ANY-NEXT: movaps {{.*#+}} xmm0 = [NaN,NaN]
; ANY-NEXT: retq
%r = fadd <2 x double> undef, <double undef, double 42.0>
ret <2 x double> %r
define <2 x double> @fsub_undef_op1_constant_vec(<2 x double> %x) {
; ANY-LABEL: fsub_undef_op1_constant_vec:
; ANY: # %bb.0:
-; ANY-NEXT: movaps {{.*#+}} xmm0 = <u,NaN>
+; ANY-NEXT: movaps {{.*#+}} xmm0 = [NaN,NaN]
; ANY-NEXT: retq
%r = fsub <2 x double> <double undef, double 42.0>, undef
ret <2 x double> %r
define <2 x double> @fsub_undef_op0_constant_vec(<2 x double> %x) {
; ANY-LABEL: fsub_undef_op0_constant_vec:
; ANY: # %bb.0:
-; ANY-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
+; ANY-NEXT: movaps {{.*#+}} xmm0 = [NaN,NaN]
; ANY-NEXT: retq
%r = fsub <2 x double> undef, <double 42.0, double undef>
ret <2 x double> %r
define <2 x double> @fmul_undef_op1_constant_vec(<2 x double> %x) {
; ANY-LABEL: fmul_undef_op1_constant_vec:
; ANY: # %bb.0:
-; ANY-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
+; ANY-NEXT: movaps {{.*#+}} xmm0 = [NaN,NaN]
; ANY-NEXT: retq
%r = fmul <2 x double> <double 42.0, double undef>, undef
ret <2 x double> %r
define <2 x double> @fmul_undef_op0_constant_vec(<2 x double> %x) {
; ANY-LABEL: fmul_undef_op0_constant_vec:
; ANY: # %bb.0:
-; ANY-NEXT: movaps {{.*#+}} xmm0 = <u,NaN>
+; ANY-NEXT: movaps {{.*#+}} xmm0 = [NaN,NaN]
; ANY-NEXT: retq
%r = fmul <2 x double> undef, <double undef, double 42.0>
ret <2 x double> %r
define <2 x double> @fdiv_undef_op1_constant_vec(<2 x double> %x) {
; ANY-LABEL: fdiv_undef_op1_constant_vec:
; ANY: # %bb.0:
-; ANY-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
+; ANY-NEXT: movaps {{.*#+}} xmm0 = [NaN,NaN]
; ANY-NEXT: retq
%r = fdiv <2 x double> <double 42.0, double undef>, undef
ret <2 x double> %r
define <2 x double> @fdiv_undef_op0_constant_vec(<2 x double> %x) {
; ANY-LABEL: fdiv_undef_op0_constant_vec:
; ANY: # %bb.0:
-; ANY-NEXT: movaps {{.*#+}} xmm0 = <u,NaN>
+; ANY-NEXT: movaps {{.*#+}} xmm0 = [NaN,NaN]
; ANY-NEXT: retq
%r = fdiv <2 x double> undef, <double undef, double 42.0>
ret <2 x double> %r
define <2 x double> @frem_undef_op1_constant_vec(<2 x double> %x) {
; ANY-LABEL: frem_undef_op1_constant_vec:
; ANY: # %bb.0:
-; ANY-NEXT: movaps {{.*#+}} xmm0 = <u,NaN>
+; ANY-NEXT: movaps {{.*#+}} xmm0 = [NaN,NaN]
; ANY-NEXT: retq
%r = frem <2 x double> <double undef, double 42.0>, undef
ret <2 x double> %r
define <2 x double> @frem_undef_op0_constant_vec(<2 x double> %x) {
; ANY-LABEL: frem_undef_op0_constant_vec:
; ANY: # %bb.0:
-; ANY-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
+; ANY-NEXT: movaps {{.*#+}} xmm0 = [NaN,NaN]
; ANY-NEXT: retq
%r = frem <2 x double> undef, <double 42.0, double undef>
ret <2 x double> %r