[PATCH] D62786: [X86] X86DAGToDAGISel::matchBitExtract(): pattern a: truncation awareness

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 3 08:45:22 PDT 2019


lebedev.ri marked an inline comment as done.
lebedev.ri added inline comments.


================
Comment at: test/CodeGen/X86/extract-lowbits.ll:22-23
 ;   b) x & ~(-1 << nbits)
 ;   c) x &  (-1 >> (32 - y))
 ;   d) x << (32 - y) >> (32 - y)
 ; are equivalent.
----------------
Thinking about it, i guess at least 2 more patterns are missing:
```
"get me all bits except y high bits"
;   c') x &  (-1 >> (y))
;   d') x << (y) >> (y)
```
... to get the 'num bits to extract' we'd need to also insert `sub 32 - y`.

I don't think we can just select these two patterns, and not look for `(32 - y)`,
because we are so late that no peephole pass will cleanup `(32 - (32 - y))` into `y`.
(That i know of?)

Similarly, i don't *think* we can instcombine these into any other pattern.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D62786





More information about the llvm-commits mailing list