Hello,
LLVM supports converting multiplication to shifting and add/sub operations if possible when one operand is a integer variable and the other is a positive constant even if the constant is not power of 2. For example, "x*5" will be converted to "x+x<<2". However, when the constant is a negative and not power of 2, it always emits "mul" even if using shifting+add/sub is possible. For example, "x*-7" should be converted to "x-x<<8" (sub r0, r0, r0, lsl #3 ) I have reported this into the bugzilla. The URL is http://llvm.org/bugs/show_bug.cgi?id=12212 The cause of the issue is in ARMISelLowering.cpp, it treats the constant ("MulAmt") as uint64_t and therefore it omits the case when MulAmt could be negative. So, I'm providing the fix for this issue. I also run the unit tests and the test suite. My fix doesn't change any result from validtion tests. I believe this is good fix. :D I'm attaching the fix (0001-Bug12212-*.patch) and an updated test case (0002-neg-mul-const-unit-test.patch) for such scenario as well as my validation run results (test_results.tar.bz2). Please review it. Thanks, Weiming Zhao
0001-Bug12212-LLVM-misses-multiply-by-non-power-of-2-negat.patch
Description: Binary data
0002-neg-mul-const-unit-test.patch
Description: Binary data
test_result.tar.bz2
Description: Binary data
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
