Open Quuxplusone opened 5 years ago
Bugzilla Link | PR42144 |
Status | NEW |
Importance | P enhancement |
Reported by | Roman Lebedev (lebedev.ri@gmail.com) |
Reported on | 2019-06-05 12:14:52 -0700 |
Last modified on | 2019-06-05 12:53:04 -0700 |
Version | trunk |
Hardware | PC Linux |
CC | craig.topper@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, spatel+llvm@rotateright.com |
Fixed by commit(s) | |
Attachments | |
Blocks | |
Blocked by | |
See also |
Not sure if it's the same, but I was looking at a similar problem that led me
to this bit of X86InstrCompiler.td:
// anyext. Define these to do an explicit zero-extend to
// avoid partial-register updates.
To avoid this, the big change that I think we want -- but probably requires
many intermediate fixes -- is to promote all 8-bit ops to 32-bit.
SelectionDAGBuilder inserted a trunc before the shl during DAG construction.
This caused DAGCombine to shrink the add -1 to 8-bits because
sTypeDesirableForOp didn't tell it not to. Lowering for the icmp created the BT
from the and/shl, but needed to extend the register type back to 32-bits to
match the register size required for the BT count input.
I'm pretty sure that even though BT only needs 5 or 6 bits for the count, the
partial register handling in the frontend and register renaming does track it
as an access to the full register 16/32/64-bit register. This means on Sandy
Bridge and later, it will trigger an H-register merge if needed. I think the
shift amounts for SHLX/SARX/SHRX are the same. The old shift instructions that
always use CL will not trigger an H-register merge.
Promote all the things is probably the best way to fix this.