[llvm] r195476 - Fix PR18014
Michael Liao
michael.liao at intel.com
Fri Nov 22 09:56:58 PST 2013
Author: hliao
Date: Fri Nov 22 11:56:57 2013
New Revision: 195476
URL: http://llvm.org/viewvc/llvm-project?rev=195476&view=rev
Log:
Fix PR18014
- When simplifying the mask generation for BLEND, check whether that mask is
also consumed by other non-BLEND insns. If true, skip that simplification.
Added:
llvm/trunk/test/CodeGen/X86/pr18014.ll
Modified:
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=195476&r1=195475&r2=195476&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Fri Nov 22 11:56:57 2013
@@ -17024,6 +17024,15 @@ static SDValue PerformSELECTCombine(SDNo
if (BitWidth == 1)
return SDValue();
+ // Check all uses of that condition operand to check whether it will be
+ // consumed by non-BLEND instructions, which may depend on all bits are set
+ // properly.
+ for (SDNode::use_iterator I = Cond->use_begin(),
+ E = Cond->use_end(); I != E; ++I)
+ if (I->getOpcode() != ISD::VSELECT)
+ // TODO: Add other opcodes eventually lowered into BLEND.
+ return SDValue();
+
assert(BitWidth >= 8 && BitWidth <= 64 && "Invalid mask size");
APInt DemandedMask = APInt::getHighBitsSet(BitWidth, 1);
Added: llvm/trunk/test/CodeGen/X86/pr18014.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/pr18014.ll?rev=195476&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/pr18014.ll (added)
+++ llvm/trunk/test/CodeGen/X86/pr18014.ll Fri Nov 22 11:56:57 2013
@@ -0,0 +1,16 @@
+; RUN: llc < %s -mtriple=x86_64-linux-pc -mcpu=penryn | FileCheck %s
+
+; Ensure PSRAD is generated as the condition is consumed by both PADD and
+; BLENDVPS. PAND requires all bits setting properly.
+
+define <4 x i32> @foo(<4 x i32>* %p, <4 x i1> %cond, <4 x i32> %v1, <4 x i32> %v2, <4 x i32> %v3) {
+ %sext_cond = sext <4 x i1> %cond to <4 x i32>
+ %t1 = add <4 x i32> %v1, %sext_cond
+ %t2 = select <4 x i1> %cond, <4 x i32> %v1, <4 x i32> %v2
+ store <4 x i32> %t2, <4 x i32>* %p
+ ret <4 x i32> %t1
+; CHECK: foo
+; CHECK: pslld
+; CHECK: psrad
+; CHECK: ret
+}
More information about the llvm-commits
mailing list