From fc2c9af99c546d644757ae06b65df69f92897ab7 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Mon, 10 Dec 2018 18:29:46 +0000 Subject: [TargetLowering] Add UNDEF folding to SimplifyDemandedVectorElts If all the demanded elements of the SimplifyDemandedVectorElts are known to be UNDEF, we can simplify to an ISD::UNDEF node. Zero constant folding will be handled in a future patch - its a little trickier as we often have bitcasted zero values. Differential Revision: https://reviews.llvm.org/D55511 llvm-svn: 348784 --- llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'llvm/lib/CodeGen') diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp index b45453b52e1..1f5ea31c815 100644 --- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -1783,8 +1783,13 @@ bool TargetLowering::SimplifyDemandedVectorElts( break; } } - assert((KnownUndef & KnownZero) == 0 && "Elements flagged as undef AND zero"); + + // Constant fold all undef cases. + // TODO: Handle zero cases as well. + if (DemandedElts.isSubsetOf(KnownUndef)) + return TLO.CombineTo(Op, TLO.DAG.getUNDEF(VT)); + return false; } -- cgit v1.2.3