Just a simple instruction save.
Details
Details
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Comment Actions
We have a general Negator infrastructure, which we could use to fold add X, Y to sub X, -Y if the latter is free. However, given how we currently use it to fold sub X, Y to add X, -Y, actually trying to do that would probably result in many new and exiting infinite combine loops, so I'm happy to take the one-off pattern...
| llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp | ||
|---|---|---|
| 1167 | Can this function be reduced to something along the lines of this? if (match(I, m_c_Add(m_OneUse(m_Shl(m_OneUse(m_Neg(m_Value(X))), m_Value(Cnt))),
m_Value(X))) {
Value *NewShl = Builder.CreateShl(X, Cnt);
return BinaryOperator::CreateSub(Other, NewShl);
} | |
| llvm/test/Transforms/InstCombine/add-shift.ll | ||
| 62–80 | This only covers one of the one-use conditions. | |
Y -> Cnt to match the name in the implementation.