x / fabs(x) -> copysign(1.0, x)
fabs(x) / x -> copysign(1.0, x)
Details
Diff Detail
Event Timeline
| lib/Transforms/InstCombine/InstCombineMulDivRem.cpp | ||
|---|---|---|
| 1240 | Dropped. | |
| lib/Transforms/InstCombine/InstCombineMulDivRem.cpp | ||
|---|---|---|
| 1246 | I tried match(&I, m_FDiv(m_Value(X), m_Intrinsic<Intrinsic::fabs>(m_Specific(X)))) and it failed to match.. uh. (this blocked me to possibly introduce m_c_FDiv) | |
| lib/Transforms/InstCombine/InstCombineMulDivRem.cpp | ||
|---|---|---|
| 1246 | You need to use m_Deferred() for that case when matching commutatively (cc @lebedev.ri ). | |
| test/Transforms/InstCombine/fabs-copysign.ll | ||
| 22–30 | Please push the new tests with baseline CHECKs as a preliminary step. | |
| lib/Transforms/InstCombine/InstCombineMulDivRem.cpp | ||
|---|---|---|
| 1246 | Thanks! (and agree) | |
Wait - there was a vector test here at 1 point, but now it's gone? Please adjust the type on one of the positive tests, so we still have that coverage.
Do we want to handle the commuted pattern too?
fabs(X) / X