Go to file
Roman Lebedev b4a1d8a84c [InstCombine] dropRedundantMaskingOfLeftShiftInput(): pat. a/b with mask (PR42563)
Summary:
And this is **finally** the interesting part of that fold!

If we have a pattern `(x & (~(-1 << maskNbits))) << shiftNbits`,
we already know (have a fold) that will drop the `& (~(-1 << maskNbits))`
mask iff `(maskNbits+shiftNbits) u>= bitwidth(x)`.
But that is actually ignorant, there's more general fold here:

In this pattern, `(maskNbits+shiftNbits)` actually correlates
with the number of low bits that will remain in the final value.
So even if `(maskNbits+shiftNbits) u< bitwidth(x)`, we can still
fold, we will just need to apply a **constant** mask afterwards:
```
Name: a, normal+mask
  %onebit = shl i32 -1, C1
  %mask = xor i32 %onebit, -1
  %masked = and i32 %mask, %x
  %r = shl i32 %masked, C2
=>
  %n0 = shl i32 %x, C2
  %n1 = add i32 C1, C2
  %n2 = zext i32 %n1 to i64
  %n3 = shl i64 -1, %n2
  %n4 = xor i64 %n3, -1
  %n5 = trunc i64 %n4 to i32
  %r = and i32 %n0, %n5
```
https://rise4fun.com/Alive/F5R

Naturally, old `%masked` will have to be one-use.
Similar fold exists for patterns c,d,e, will post patch later.

https://bugs.llvm.org/show_bug.cgi?id=42563

Reviewers: spatel, nikic, xbolva00

Reviewed By: spatel

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D67677

llvm-svn: 372629
2019-09-23 17:04:14 +00:00
clang Fix __is_fundamental to accept nullptr_t 2019-09-23 16:02:46 +00:00
clang-tools-extra [Clang-doc] NFC: Fixed link to llvm bugs in documentation 2019-09-23 16:55:13 +00:00
compiler-rt [compiler-rt] Fix lint check failure on comments 2019-09-22 15:31:03 +00:00
debuginfo-tests Make nrvo-string test more robust. 2019-06-27 20:38:37 +00:00
libc Add a director, along with README.txt and LICENSE.txt, for libc. 2019-09-16 21:39:08 +00:00
libclc Revert "Rename F_{None,Text,Append} to OF_{None,Text,Append}. NFC" 2019-08-05 17:23:23 +00:00
libcxx [libc++] Mark iostreams test as XFAIL on older macOSes 2019-09-23 15:40:47 +00:00
libcxxabi Update XFAIL list for new GCC versions 2019-09-13 18:43:29 +00:00
libunwind Unwind: avoid warning about unused typedef 2019-09-20 20:46:33 +00:00
lld [LLD][ELF] - Simplify getFlagsFromEmulation(). NFCI. 2019-09-23 09:55:10 +00:00
lldb [LLDB] Fix logically dead code 2019-09-23 14:05:51 +00:00
llgo IR: Support parsing numeric block ids, and emit them in textual output. 2019-03-22 18:27:13 +00:00
llvm [InstCombine] dropRedundantMaskingOfLeftShiftInput(): pat. a/b with mask (PR42563) 2019-09-23 17:04:14 +00:00
openmp [OpenMP] Change initialization of __kmp_global 2019-09-04 17:47:37 +00:00
parallel-libs Fix typos throughout the license files that somehow I and my reviewers 2019-01-21 09:52:34 +00:00
polly [CodeGen] Handle outlining of CopyStmts. 2019-09-17 22:59:43 +00:00
pstl [pstl] Allow customizing whether per-TU insulation is provided 2019-08-13 12:49:00 +00:00
.arcconfig Update monorepo .arcconfig with new project callsign. 2019-01-31 14:34:59 +00:00
.clang-format Add .clang-tidy and .clang-format files to the toplevel of the 2019-01-29 16:43:16 +00:00
.clang-tidy Disable tidy checks with too many hits 2019-02-01 11:20:13 +00:00
.git-blame-ignore-revs Add LLDB reformatting to .git-blame-ignore-revs 2019-09-04 09:31:55 +00:00
.gitignore Add a newline at the end of the file 2019-09-04 06:33:46 +00:00
README.md

README.md

The LLVM Compiler Infrastructure

This directory and its subdirectories contain source code for LLVM, a toolkit for the construction of highly optimized compilers, optimizers, and runtime environments.