[llvm] [CodeGenPrepare] Transform `shl X, cttz(Y)` to `mul (Y & -Y), X` if cttz is unsupported (PR #85066)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 21 07:44:40 PDT 2024


================
@@ -8396,7 +8396,29 @@ bool CodeGenPrepare::optimizeInst(Instruction *I, ModifyDT &ModifiedDT) {
     return true;
 
   switch (I->getOpcode()) {
-  case Instruction::Shl:
+  case Instruction::Shl: {
+    // shl X, cttz(Y) -> mul (Y & -Y), X if cttz is unsupported on the target.
----------------
dtcxzyw wrote:

I put `X` in RHS because it may be a constant.


https://github.com/llvm/llvm-project/pull/85066


More information about the llvm-commits mailing list