[llvm] r347403 - [x86] fix predicate for avoiding vblendv
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 21 10:02:50 PST 2018
Author: spatel
Date: Wed Nov 21 10:02:50 2018
New Revision: 347403
URL: http://llvm.org/viewvc/llvm-project?rev=347403&view=rev
Log:
[x86] fix predicate for avoiding vblendv
It only makes sense to produce the logic ops when 1 of the
constants is +0.0. Otherwise, go with vblendv to reduce code.
Modified:
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
llvm/trunk/test/CodeGen/X86/vselect-zero.ll
Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=347403&r1=347402&r2=347403&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Wed Nov 21 10:02:50 2018
@@ -19632,7 +19632,7 @@ SDValue X86TargetLowering::LowerSELECT(S
// of 3 logic instructions for size savings and potentially speed.
// Unfortunately, there is no scalar form of VBLENDV.
- // If either operand is a constant, don't try this. We can expect to
+ // If either operand is a +0.0 constant, don't try this. We can expect to
// optimize away at least one of the logic instructions later in that
// case, so that sequence would be faster than a variable blend.
@@ -19640,13 +19640,10 @@ SDValue X86TargetLowering::LowerSELECT(S
// uses XMM0 as the selection register. That may need just as many
// instructions as the AND/ANDN/OR sequence due to register moves, so
// don't bother.
-
- if (Subtarget.hasAVX() &&
- !isa<ConstantFPSDNode>(Op1) && !isa<ConstantFPSDNode>(Op2)) {
-
+ if (Subtarget.hasAVX() && !isNullFPConstant(Op1) &&
+ !isNullFPConstant(Op2)) {
// Convert to vectors, do a VSELECT, and convert back to scalar.
// All of the conversions should be optimized away.
-
MVT VecVT = VT == MVT::f32 ? MVT::v4f32 : MVT::v2f64;
SDValue VOp1 = DAG.getNode(ISD::SCALAR_TO_VECTOR, DL, VecVT, Op1);
SDValue VOp2 = DAG.getNode(ISD::SCALAR_TO_VECTOR, DL, VecVT, Op2);
Modified: llvm/trunk/test/CodeGen/X86/vselect-zero.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vselect-zero.ll?rev=347403&r1=347402&r2=347403&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/vselect-zero.ll (original)
+++ llvm/trunk/test/CodeGen/X86/vselect-zero.ll Wed Nov 21 10:02:50 2018
@@ -88,10 +88,8 @@ define double @fsel_nonzero_false_val(do
; AVX-LABEL: fsel_nonzero_false_val:
; AVX: # %bb.0:
; AVX-NEXT: vcmpeqsd %xmm1, %xmm0, %xmm0
-; AVX-NEXT: vandpd %xmm2, %xmm0, %xmm1
-; AVX-NEXT: vmovsd {{.*#+}} xmm2 = mem[0],zero
-; AVX-NEXT: vandnpd %xmm2, %xmm0, %xmm0
-; AVX-NEXT: vorpd %xmm1, %xmm0, %xmm0
+; AVX-NEXT: vmovsd {{.*#+}} xmm1 = mem[0],zero
+; AVX-NEXT: vblendvpd %xmm0, %xmm2, %xmm1, %xmm0
; AVX-NEXT: retq
%cond = fcmp oeq double %x, %y
%r = select i1 %cond, double %z, double 42.0
@@ -112,9 +110,7 @@ define double @fsel_nonzero_true_val(dou
; AVX: # %bb.0:
; AVX-NEXT: vcmpeqsd %xmm1, %xmm0, %xmm0
; AVX-NEXT: vmovsd {{.*#+}} xmm1 = mem[0],zero
-; AVX-NEXT: vandpd %xmm1, %xmm0, %xmm1
-; AVX-NEXT: vandnpd %xmm2, %xmm0, %xmm0
-; AVX-NEXT: vorpd %xmm1, %xmm0, %xmm0
+; AVX-NEXT: vblendvpd %xmm0, %xmm1, %xmm2, %xmm0
; AVX-NEXT: retq
%cond = fcmp oeq double %x, %y
%r = select i1 %cond, double 42.0, double %z
More information about the llvm-commits
mailing list