File tree 2 files changed +11
-4
lines changed 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> {
368
368
InstructionCost Invalid = InstructionCost::getInvalid ();
369
369
InstructionCost Cost (TTI::TCC_Basic);
370
370
371
- if (Opcode != Instruction::Add)
371
+ if (Opcode != Instruction::Add && Opcode != Instruction::Sub )
372
372
return Invalid;
373
373
374
374
if (InputTypeA != InputTypeB)
Original file line number Diff line number Diff line change @@ -317,13 +317,20 @@ void VPPartialReductionRecipe::execute(VPTransformState &State) {
317
317
State.setDebugLocFrom (getDebugLoc ());
318
318
auto &Builder = State.Builder ;
319
319
320
- assert (getOpcode () == Instruction::Add &&
321
- " Unhandled partial reduction opcode" );
322
-
323
320
Value *BinOpVal = State.get (getOperand (0 ));
324
321
Value *PhiVal = State.get (getOperand (1 ));
325
322
assert (PhiVal && BinOpVal && " Phi and Mul must be set" );
326
323
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
+
327
334
Type *RetTy = PhiVal->getType ();
328
335
329
336
CallInst *V = Builder.CreateIntrinsic (
You can’t perform that action at this time.
0 commit comments