7 Commits

Author SHA1 Message Date
David Green
07d6af6a71 [AArch64] Fold And/Or into CSel if possible
If we have `and x, (csel 0, 1, cc)` and we know that x is 0/1, then we
can emit a `csel ZR, x, cc`. Similarly for `or x, (csel 0, 1, cc)` we
can emit `csinc x, ZR, cc`. This can help where we can not otherwise
general ccmp instructions.

Differential Revision: https://reviews.llvm.org/D141119
2023-01-09 11:52:37 +00:00
zhongyunde
3651bc83b6 [AArch64] Optimize cmp chain before legalization
* For case bcmp9, there is extras AND and EXTEND int the chain of OR/XOR,
  which prevent the transform, so enable the optimize before legalization.

* The key IR frag related:
      t37: i32,ch = load<(load (s8) from %ir.4), anyext from i8> t0, t11, undef:i64
        t12: i64 = add t4, Constant:i64<8>
      t38: i32,ch = load<(load (s8) from %ir.5), anyext from i8> t0, t12, undef:i64
    t39: i32 = xor t37, t38
  t40: i64 = any_extend t39
t42: i64 = and t40, Constant:i64<255>

Depends on D138398 to fix combine_setcc_glue

Reviewed By: dmgreen, bcl5980
Differential Revision: https://reviews.llvm.org/D137936
2022-11-23 19:43:44 +08:00
zhongyunde
894f9e54f5 [AArch64] Optimize more memcmp when the result is tested for [in]equality with 0
We already surpport the or (xor a, b), (xor c, d) with D136244, while it should
capture more cases than just bcmp according the comment on
https://reviews.llvm.org/D136672, so this patch try to fold continuous
comparison series.

Also add a new callsite in LowerSETCC to address some cases folded And in the
stage of `Optimized type-legalized selection`.
Depends on D136244

Reviewed By: dmgreen, bcl5980
Differential Revision: https://reviews.llvm.org/D137721
2022-11-13 11:02:34 +08:00
zhongyunde
63a46385f2 Recommit [AArch64] Optimize memcmp when the result is tested for [in]equality with 0
Fixes 1st issue of https://github.com/llvm/llvm-project/issues/58061
Fixes the crash of https://github.com/llvm/llvm-project/issues/58675

Reviewed By: dmgreen, efriedma
Differential Revision: https://reviews.llvm.org/D136244
2022-10-30 02:04:02 +08:00
Paul Kirth
1c06817576 Revert "[AArch64] Optimize memcmp when the result is tested for [in]equality with 0"
This reverts commit 01ff511593d1a4920fa3c1d450ad2077661e0bdc.

It triggers an assertion failure in SelectionDAG.cpp

see https://github.com/llvm/llvm-project/issues/58675 for details.
2022-10-28 23:18:21 +00:00
zhongyunde
01ff511593 [AArch64] Optimize memcmp when the result is tested for [in]equality with 0
Fixes 1st issue of https://github.com/llvm/llvm-project/issues/58061

Reviewed By: dmgreen, efriedma
Differential Revision: https://reviews.llvm.org/D136244
2022-10-28 07:52:47 +08:00
chenglin.bi
e95c74b423 [AArch64] Add precommit test for bcmp; NFC 2022-10-25 17:23:03 +08:00