llvm.org GIT mirror llvm / 52cdffd
[DAGCombiner] make folds of binops safe for opcodes that produce >1 value This is no-functional-change-intended currently because the definition of isBinOp() only includes opcodes that produce 1 value. But if we share that implementation with isCommutativeBinOp() as proposed in D62191, then we need to make sure that the callers bail out for opcodes that they are not prepared to handle correctly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361547 91177308-0d34-0410-b5e6-96231b3b80d8 Sanjay Patel 5 months ago
1 changed file(s) with 7 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
19671967 }
19681968
19691969 SDValue DAGCombiner::foldBinOpIntoSelect(SDNode *BO) {
1970 assert(TLI.isBinOp(BO->getOpcode()) && "Unexpected binary operator");
1970 assert(TLI.isBinOp(BO->getOpcode()) && BO->getNumValues() == 1 &&
1971 "Unexpected binary operator");
19711972
19721973 // Don't do this unless the old select is going away. We want to eliminate the
19731974 // binary operator, not replace a binop with a select.
1617116172 SDValue Vec = ExtElt->getOperand(0);
1617216173 SDValue Index = ExtElt->getOperand(1);
1617316174 auto *IndexC = dyn_cast(Index);
16174 if (!IndexC || !TLI.isBinOp(Vec.getOpcode()) || !Vec.hasOneUse())
16175 if (!IndexC || !TLI.isBinOp(Vec.getOpcode()) || !Vec.hasOneUse() ||
16176 Vec.getNode()->getNumValues() != 1)
1617516177 return SDValue();
1617616178
1617716179 // Targets may want to avoid this to prevent an expensive register transfer.
1741117413 SelectionDAG &DAG) {
1741217414 const TargetLowering &TLI = DAG.getTargetLoweringInfo();
1741317415 SDValue BinOp = Extract->getOperand(0);
17414 if (!TLI.isBinOp(BinOp.getOpcode()))
17416 if (!TLI.isBinOp(BinOp.getOpcode()) || BinOp.getNode()->getNumValues() != 1)
1741517417 return SDValue();
1741617418
1741717419 SDValue Bop0 = BinOp.getOperand(0), Bop1 = BinOp.getOperand(1);
1745517457 // feeding an extract subvector.
1745617458 const TargetLowering &TLI = DAG.getTargetLoweringInfo();
1745717459 SDValue BinOp = peekThroughBitcasts(Extract->getOperand(0));
17458 if (!TLI.isBinOp(BinOp.getOpcode()))
17460 if (!TLI.isBinOp(BinOp.getOpcode()) || BinOp.getNode()->getNumValues() != 1)
1745917461 return SDValue();
1746017462
1746117463 // The binop must be a vector type, so we can extract some fraction of it.
1826718269 if (SVN->isSplat() && SVN->getSplatIndex() < (int)NumElts) {
1826818270 int SplatIndex = SVN->getSplatIndex();
1826918271 if (TLI.isExtractVecEltCheap(VT, SplatIndex) &&
18270 TLI.isBinOp(N0.getOpcode())) {
18272 TLI.isBinOp(N0.getOpcode()) && N0.getNode()->getNumValues() == 1) {
1827118273 // splat (vector_bo L, R), Index -->
1827218274 // splat (scalar_bo (extelt L, Index), (extelt R, Index))
1827318275 SDValue L = N0.getOperand(0), R = N0.getOperand(1);