forked from OSchip/llvm-project
96e10b5a9e
This is essentially a recommit of r285893, but with a correctness fix. The problem of the original commit was that this: bic r5, r7, #31 cbz r5, .LBB2_10 got rewritten into: lsrs r5, r7, #5 beq .LBB2_10 The result in destination register r5 is not the same and this is incorrect when r5 is not dead. So this fix includes checking the uses of the AND destination register. And also, compared to the original commit, some regression tests didn't need changing anymore because of this extra check. For completeness, this was the original commit message: For the common pattern (CMPZ (AND x, #bitmask), #0), we can do some more efficient instruction selection if the bitmask is one consecutive sequence of set bits (32 - clz(bm) - ctz(bm) == popcount(bm)). 1) If the bitmask touches the LSB, then we can remove all the upper bits and set the flags by doing one LSLS. 2) If the bitmask touches the MSB, then we can remove all the lower bits and set the flags with one LSRS. 3) If the bitmask has popcount == 1 (only one set bit), we can shift that bit into the sign bit with one LSLS and change the condition query from NE/EQ to MI/PL (we could also implement this by shifting into the carry bit and branching on BCC/BCS). 4) Otherwise, we can emit a sequence of LSLS+LSRS to remove the upper and lower zero bits of the mask. 1-3 require only one 16-bit instruction and can elide the CMP. 4 requires two 16-bit instructions but can elide the CMP and doesn't require materializing a complex immediate, so is also a win. Differential Revision: https://reviews.llvm.org/D27761 llvm-svn: 289794 |
||
---|---|---|
.. | ||
2007-01-31-RegInfoAssert.ll | ||
2007-02-02-JoinIntervalsCrash.ll | ||
2007-05-05-InvalidPushPop.ll | ||
2009-06-18-ThumbCommuteMul.ll | ||
2009-07-20-TwoAddrBug.ll | ||
2009-07-27-PEIAssert.ll | ||
2009-08-12-ConstIslandAssert.ll | ||
2009-08-12-RegInfoAssert.ll | ||
2009-08-20-ISelBug.ll | ||
2009-12-17-pre-regalloc-taildup.ll | ||
2010-06-18-SibCallCrash.ll | ||
2010-07-01-FuncAlign.ll | ||
2010-07-15-debugOrdering.ll | ||
2011-05-11-DAGLegalizer.ll | ||
2011-06-16-NoGPRs.ll | ||
2011-EpilogueBug.ll | ||
2012-04-26-M0ISelBug.ll | ||
2014-06-10-thumb1-ldst-opt-bug.ll | ||
DbgValueOtherTargets.test | ||
PR17309.ll | ||
and_neg.ll | ||
asmprinter-bug.ll | ||
barrier.ll | ||
bic_imm.ll | ||
callee_save.ll | ||
cmp-add-fold.ll | ||
cmp-fold.ll | ||
constants.ll | ||
copy_thumb.ll | ||
cortex-m0-unaligned-access.ll | ||
dyn-stackalloc.ll | ||
fastcc.ll | ||
fpconv.ll | ||
fpow.ll | ||
frame_thumb.ll | ||
iabs.ll | ||
inlineasm-imm-thumb.ll | ||
inlineasm-thumb.ll | ||
ispositive.ll | ||
large-stack.ll | ||
ldm-merge-call.ll | ||
ldm-merge-struct.ll | ||
ldm-stm-base-materialization-thumb2.ll | ||
ldm-stm-base-materialization.ll | ||
ldm-stm-postinc.ll | ||
ldr_ext.ll | ||
ldr_frame.ll | ||
lit.local.cfg | ||
long-setcc.ll | ||
long.ll | ||
long_shift.ll | ||
mature-mc-support.ll | ||
mul.ll | ||
pop.ll | ||
push.ll | ||
rev.ll | ||
segmented-stacks-dynamic.ll | ||
segmented-stacks.ll | ||
select.ll | ||
sjljehprepare-lower-vector.ll | ||
stack-access.ll | ||
stack-coloring-without-frame-ptr.ll | ||
stack-frame.ll | ||
stack_guard_remat.ll | ||
stm-merge.ll | ||
thumb-imm.ll | ||
thumb-ldm.ll | ||
thumb-shrink-wrapping.ll | ||
trap.ll | ||
triple.ll | ||
tst_teq.ll | ||
unord.ll | ||
vargs.ll |