[X86] X86DAGToDAGISel::matchBitExtract(): pattern c: truncation awareness

Summary:
The one thing of note here is that the 'bitwidth' constant (32/64) was previously pessimistic.
Given `x & (-1 >> (C - z))`, we were taking `C` to be `bitwidth(x)`, but in reality
we want `(-1 >> (C - z))` pattern to mean "low z bits must be all-ones".
And for that, `C` should be `bitwidth(-1 >> (C - z))`, i.e. of the shift operation itself.

Last pattern D does not seem to exhibit any of these truncation issues.
Although it has the opposite problem - if we extract low bits (no shift) from i64,
and then truncate to i32, then we fail to shrink this 64-bit extraction into 32-bit extraction.

Reviewers: RKSimon, craig.topper, spatel

Reviewed By: RKSimon

Subscribers: llvm-commits

Tags: #llvm

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

llvm-svn: 364419
3 files changed
tree: f028529ba0f7b2cb69cd54e1538f47e1123326ed
  1. .github/
  2. clang/
  3. clang-tools-extra/
  4. compiler-rt/
  5. debuginfo-tests/
  6. libclc/
  7. libcxx/
  8. libcxxabi/
  9. libunwind/
  10. lld/
  11. lldb/
  12. llgo/
  13. llvm/
  14. openmp/
  15. parallel-libs/
  16. polly/
  17. pstl/
  18. .arcconfig
  19. .clang-format
  20. .clang-tidy
  21. .gitignore
  22. 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.