This patch enables folding under -ffast-math flag sqrt(a) * sqrt(b) -> sqrt(a*b)
Details
Diff Detail
Event Timeline
lib/Transforms/InstCombine/InstCombineMulDivRem.cpp | ||
---|---|---|
626 | Note that we have a fast-math-flag specifically for reassociation now (as well as a FMF for approximation of math functions). I'm not sure what combination would be needed for this transform. It's independent of this patch, but something to think about. | |
731 | What if sqrt(a) or sqrt(b) has another use besides the multiply? I don't think we want to do the transform in that case. Either way, please add a test for that kind of example. | |
733–739 | You can use: match(Op0, m_Intrinsic<Intrinsic::sqrt>( ... to simplify this code. | |
test/Transforms/InstCombine/fmul.ll | ||
185–199 ↗ | (On Diff #127243) | Please use the script at utils/update_test_checks.py to auto-generate the checks for any tests you add. The checks will be more exact and have regex for the variable names, so they'll be more robust. |
test/Transforms/InstCombine/fmul.ll | ||
---|---|---|
195–199 ↗ | (On Diff #127243) | Please add a negative test showing that this combine doesn't fire unless the conditions are met (allows reassociation/fast-math, etc..) |
LGTM
lib/Transforms/InstCombine/InstCombineMulDivRem.cpp | ||
---|---|---|
737 | Just a few small bits here:
|
Note that we have a fast-math-flag specifically for reassociation now (as well as a FMF for approximation of math functions). I'm not sure what combination would be needed for this transform. It's independent of this patch, but something to think about.