HomePhabricator

[DAGCombine][X86][Thumb2/LowOverheadLoops] `A - (A & C)` -> `A & (~C)` fold…

Authored by lebedev.ri on Jan 3 2020, 4:38 AM.

Description

[DAGCombine][X86][Thumb2/LowOverheadLoops] A - (A & C) -> A & (~C) fold (PR44448)

While we do manage to fold integer-typed IR in middle-end,
we can't do that for the main motivational case of pointers.

There is @llvm.ptrmask() intrinsic which may or may not be helpful,
but i'm not sure it is fully considered canonical yet,
not everything is fully aware of it likely.

Name: PR44448 ptr - (ptr & C) -> ptr & (~C)
%bias = and i32 %ptr, C
%r = sub i32 %ptr, %bias

=>

%r = and i32 %ptr, ~C

See

https://bugs.llvm.org/show_bug.cgi?id=44448
https://reviews.llvm.org/D71499

Details

Committed
lebedev.riJan 3 2020, 6:55 AM
Parents
rGe4de8db67eb7: [NFC][DAGCombine][X86] Tests for 'A - (A & C)' pattern (PR44448)
Branches
Unknown
Tags
Unknown