[PATCH] D123453: [InstCombine] Fold mul nuw+lshr to a single multiplication when the latter is a factor
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 20 07:53:34 PDT 2022
spatel added a comment.
In D123453#3461148 <https://reviews.llvm.org/D123453#3461148>, @bcl5980 wrote:
> Backend is not easy to figure out the case as we need to loop all use of mul's operand 0 to find the candidate.
Ok - I agree that the posted examples don't look like wins. There is no quick fix for the backend, so we can leave the one-use check in for now. Please add a code comment though to explain why have the one-use limitation.
If you want to make the other transform (for "shl") consistent with this one by adding a one-use check to it too, that can be a follow-up patch. That transform has been around for a long time, so it is possible that someone may notice an independent performance difference from that change.
================
Comment at: llvm/test/Transforms/InstCombine/shift-logic.ll:275
;
%2 = mul nuw nsw i64 %0, 52
%3 = lshr i64 %2, 2
----------------
If we do not propagate the 'nsw' on this, we will not be able to recover it in general:
https://alive2.llvm.org/ce/z/tbckkt
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D123453/new/
https://reviews.llvm.org/D123453
More information about the llvm-commits
mailing list