[PATCH] D145890: [InstCombine] Generate better code for std::bit_floor from libstdc++

Kazu Hirata via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 9 15:13:03 PDT 2023


kazu marked 2 inline comments as done.
kazu added a comment.

Please take a look.  Thanks!



================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp:3325
+  return cast<Instruction>(
+      Builder.CreateLShr(ConstantInt::get(NType, ShiftedBit), NewCTLZ));
+}
----------------
goldstein.w.n wrote:
> This can be exact:
> https://alive2.llvm.org/ce/z/Enurag
> 
> I think:
> 
> ```
> BinaryOperator *BO = BinaryOperator::CreateLShr(ConstantInt::get(NType, ShiftedBit), NewCTLZ);
>   BO->setIsExact();
>   return BO;
> ``` 
> 
> Should work.
If I do this, I get:

```
llvm/include/llvm/Transforms/Utils/InstructionWorklist.h:60: void llvm::InstructionWorklist::push(llvm::Instruction *): Assertion `I->getParent() && "Instruction not inserted yet?"' failed.
```




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145890/new/

https://reviews.llvm.org/D145890



More information about the llvm-commits mailing list