| commit | 265b032bdae0550de69ff52b4ef9deaf78bae522 | [log] [tgz] |
|---|---|---|
| author | kper <kevin.per@protonmail.com> | Wed Sep 10 17:54:18 2025 +0200 |
| committer | GitHub <noreply@github.com> | Wed Sep 10 15:54:18 2025 +0000 |
| tree | 43b0d0f3ed102a84a84d10b4d33fade5a2007c47 | |
| parent | 61e4d2312d59d059f775734a3a7c96a6914c07b7 [diff] |
[InstCombine] Added optimisation for trunc (Pow2 >> x) to i1 (#157030) Closes #156898 I have added two cases. The first one matches when the constant is exactly power of 2. The second case was to address the general case mentioned in the linked issue. I, however, did not really solve the general case. We can only emit a `icmp ult` if all the bits are one and that's only the case when the constant + 1 is a power of 2. Otherwise, we need to create `icmp eq` for every bit that is one. Here are a few examples which won't be working with the two cases: - constant is `9`: https://alive2.llvm.org/ce/z/S5FLJZ - subrange in `56`: https://alive2.llvm.org/ce/z/yn_ZNG - and finally an example as worst case (because it alternates the bits): https://alive2.llvm.org/ce/z/nDitNA
Welcome to the LLVM project!
This repository contains the source code for LLVM, a toolkit for the construction of highly optimized compilers, optimizers, and run-time environments.
The LLVM project has multiple components. The core of the project is itself called “LLVM”. This contains all of the tools, libraries, and header files needed to process intermediate representations and convert them into object files. Tools include an assembler, disassembler, bitcode analyzer, and bitcode optimizer.
C-like languages use the Clang frontend. This component compiles C, C++, Objective-C, and Objective-C++ code into LLVM bitcode -- and from there into object files, using LLVM.
Other components include: the libc++ C++ standard library, the LLD linker, and more.
Consult the Getting Started with LLVM page for information on building and running LLVM.
For information on how to contribute to the LLVM project, please take a look at the Contributing to LLVM guide.
Join the LLVM Discourse forums, Discord chat, LLVM Office Hours or Regular sync-ups.
The LLVM project has adopted a code of conduct for participants to all modes of communication within the project.