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

Wang Pengcheng via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 13 20:19:03 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.
----------------
wangpc-pp wrote:

`shl X, cttz(Y) -> mul (Y & -Y), X` -> `shl X, cttz(Y) -> X, mul (Y & -Y)`?
I missed the `X` at first galance.

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


More information about the llvm-commits mailing list