File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -368,7 +368,7 @@ class AArch64TTIImpl : public BasicTTIImplBase<AArch64TTIImpl> {
368368 InstructionCost Invalid = InstructionCost::getInvalid ();
369369 InstructionCost Cost (TTI::TCC_Basic);
370370
371- if (Opcode != Instruction::Add)
371+ if (Opcode != Instruction::Add && Opcode != Instruction::Sub )
372372 return Invalid;
373373
374374 if (InputTypeA != InputTypeB)
Original file line number Diff line number Diff line change @@ -317,13 +317,20 @@ void VPPartialReductionRecipe::execute(VPTransformState &State) {
317317 State.setDebugLocFrom (getDebugLoc ());
318318 auto &Builder = State.Builder ;
319319
320- assert (getOpcode () == Instruction::Add &&
321- " Unhandled partial reduction opcode" );
322-
323320 Value *BinOpVal = State.get (getOperand (0 ));
324321 Value *PhiVal = State.get (getOperand (1 ));
325322 assert (PhiVal && BinOpVal && " Phi and Mul must be set" );
326323
324+ unsigned Opcode = getOpcode ();
325+
326+ if (Opcode == Instruction::Sub) {
327+ bool HasNSW = cast<Instruction>(BinOpVal)->hasNoSignedWrap ();
328+ BinOpVal = Builder.CreateNeg (BinOpVal, " " , HasNSW);
329+ Opcode = Instruction::Add;
330+ }
331+
332+ assert (Opcode == Instruction::Add && " Unhandled partial reduction opcode" );
333+
327334 Type *RetTy = PhiVal->getType ();
328335
329336 CallInst *V = Builder.CreateIntrinsic (
You can’t perform that action at this time.
0 commit comments