Replace division of positive signed integer by power of 2 with a simple shift.
Diff Detail
Diff Detail
Event Timeline
Comment Actions
You don't have any testcases.
What stops you from transforming sdiv i32 %x, 2 into ashr i32 %x, 1 ? Such a transform wouldn't be correct because the two are not equivalent when %x is -1.
The transform on line 1215 already tries to turn signed division into unsigned division when it is safe to do so. From there, unsigned division will be canonicalized into a shift when we can.
lib/Transforms/InstCombine/InstCombineMulDivRem.cpp | ||
---|---|---|
1138–1139 | This doesn't look correctly formatted, please use clang-format. |
This doesn't look correctly formatted, please use clang-format.