diff --git a/llvm/lib/Target/PowerPC/PPCInstrVSX.td b/llvm/lib/Target/PowerPC/PPCInstrVSX.td --- a/llvm/lib/Target/PowerPC/PPCInstrVSX.td +++ b/llvm/lib/Target/PowerPC/PPCInstrVSX.td @@ -1505,6 +1505,13 @@ AltVSXFMARel; } + // Additional fnmsub patterns: -a*c + b == -(a*c - b) + def : Pat<(fma (fneg f32:$A), f32:$C, f32:$B), + (XSNMSUBASP $B, $C, $A)>; + def : Pat<(fma f32:$A, (fneg f32:$C), f32:$B), + (XSNMSUBASP $B, $C, $A)>; + + // Single Precision Conversions (FP <-> INT) def XSCVSXDSP : XX2Form<60, 312, (outs vssrc:$XT), (ins vsfrc:$XB), diff --git a/llvm/test/CodeGen/PowerPC/fdiv.ll b/llvm/test/CodeGen/PowerPC/fdiv.ll --- a/llvm/test/CodeGen/PowerPC/fdiv.ll +++ b/llvm/test/CodeGen/PowerPC/fdiv.ll @@ -5,9 +5,8 @@ ; CHECK-LABEL: foo: ; CHECK: # %bb.0: ; CHECK-NEXT: xsresp 3, 2 -; CHECK-NEXT: fneg 2, 2 ; CHECK-NEXT: xsmulsp 0, 1, 3 -; CHECK-NEXT: xsmaddasp 1, 2, 0 +; CHECK-NEXT: xsnmsubasp 1, 0, 2 ; CHECK-NEXT: xsmaddasp 0, 3, 1 ; CHECK-NEXT: fmr 1, 0 ; CHECK-NEXT: blr