This is a issue found when investigate https://reviews.llvm.org/D60395.
exact flag is missing when opt combine 0 - (X sdiv C) -> (X sdiv -C)
Details
Diff Detail
Event Timeline
Looks good, but a question re tests.
---------------------------------------- Optimization: zz Precondition: ((C != 1) && (C != -128)) %div = sdiv exact i8 %x, C %r = sub i8 0, %div => %r = sdiv exact i8 %x, -C Done: 1 Optimization is correct!
llvm/test/Transforms/InstCombine/div.ll | ||
---|---|---|
763 | Please add more tests.
|
please precommit the tests
llvm/test/Transforms/InstCombine/div.ll | ||
---|---|---|
783 | tests are faulty, contain nsw despite the name |
Thanks for your comments Roman @lebedev.ri . Updated.
llvm/test/Transforms/InstCombine/div.ll | ||
---|---|---|
783 | oops. fixed. |
llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp | ||
---|---|---|
1696 ↗ | (On Diff #194116) | Uhm. CC @spatel |
llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp | ||
---|---|---|
1696 ↗ | (On Diff #194116) | Yes, if this patch has not been reverted yet, it probably should be. It's not correct for arbitrary vector constants. We can either limit this to splat constants (m_APInt) or do the more involved element-by-element check. If the divisor has an undef element, we have immediate UB, so anything goes. But we might want to do something better? I haven't looked at this patch closely yet. |
llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp | ||
---|---|---|
1696 ↗ | (On Diff #194116) | Note that *this* patch only fixed propagation of exact. |
llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp | ||
---|---|---|
1696 ↗ | (On Diff #194116) | ... and it won't be possible to revert the original patch, since it is here for 9+ years. |
llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp | ||
---|---|---|
1696 ↗ | (On Diff #194116) |
Please add more tests.