@@ -964,6 +964,7 @@ namespace IGC
964
964
case Instruction::FSub:
965
965
match = MatchFrc (I) ||
966
966
MatchLrp (I) ||
967
+ MatchPredAdd (I) ||
967
968
MatchMad (I) ||
968
969
MatchAbsNeg (I) ||
969
970
MatchModifier (I);
@@ -1699,8 +1700,7 @@ namespace IGC
1699
1700
}
1700
1701
}
1701
1702
1702
- // FSub is not supported currently due to addional instruction requirement
1703
- assert (I.getOpcode () == Instruction::FAdd);
1703
+ assert (I.getOpcode () == Instruction::FAdd || I.getOpcode () == Instruction::FSub);
1704
1704
for (uint iAdd = 0 ; iAdd < 2 && !found; iAdd++)
1705
1705
{
1706
1706
Value* src = I.getOperand (iAdd);
@@ -1740,17 +1740,32 @@ namespace IGC
1740
1740
continue ;
1741
1741
}
1742
1742
1743
+ // % 97 = select i1 %res_s48, float 1.000000e+00, float 0.000000e+00
1744
+ // %102 = fmul fast float %97 %98
1745
+
1746
+ // case 1 (add)
1743
1747
// Before match
1744
- // % 97 = select i1 %res_s48, float 1.000000e+00, float 0.000000e+00
1745
- // %102 = fmul fast float %97 %98
1746
- // %105 = fadd %102 %103
1748
+ // %105 = fadd %102 %103
1749
+ // After match
1750
+ // %105 = %103
1751
+ // (%res_s48) %105 = fadd %105 %98
1747
1752
1753
+ // case 2 (fsub match @ iAdd = 0)
1754
+ // Before match
1755
+ // %105 = fsub %102 %103
1748
1756
// After match
1749
- // %105 = %103
1750
- // (%res_s48) %105 = fadd %103 %98
1757
+ // %105 = - %103
1758
+ // (%res_s48) %105 = fadd %105 %98
1751
1759
1752
- // sources[0]: add operand (i.e. %103 above)
1753
- // sources[1]: mul operand (i.e. %98 above)
1760
+ // case 3 (fsub match @ iAdd = 1)
1761
+ // Before match
1762
+ // %105 = fsub %103 %102
1763
+ // After match
1764
+ // %105 = %103
1765
+ // (%res_s48) %98 = fadd %105 -%98
1766
+
1767
+ // sources[0]: store add operand (i.e. %103 above)
1768
+ // sources[1]: store mul operand (i.e. %98 above)
1754
1769
1755
1770
sources[0 ] = I.getOperand (1 ^ iAdd);
1756
1771
sources[1 ] = mul->getOperand (1 ^ iMul);
@@ -1760,6 +1775,11 @@ namespace IGC
1760
1775
GetModifier (*sources[1 ], src_mod[1 ], sources[1 ]);
1761
1776
GetModifier (*pred, pred_mod, pred);
1762
1777
1778
+ if (I.getOpcode () == Instruction::FSub)
1779
+ {
1780
+ src_mod[iAdd] = CombineModifier (EMOD_NEG, src_mod[iAdd]);
1781
+ }
1782
+
1763
1783
found = true ;
1764
1784
break ;
1765
1785
} // if (llvm::SelectInst* selInst = dyn_cast<SelectInst>(mul->getOperand(iMul)))
0 commit comments