[all-commits] [llvm/llvm-project] c0cbe3: [NFC][DAGCombine][X86][AArch64] Tests for 'A - (A ...
Roman Lebedev via All-commits
all-commits at lists.llvm.org
Fri Jan 3 02:59:46 PST 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: c0cbe3fbb7d6b3f197b05a47a2cc25ccb7977629
https://github.com/llvm/llvm-project/commit/c0cbe3fbb7d6b3f197b05a47a2cc25ccb7977629
Author: Roman Lebedev <lebedev.ri at gmail.com>
Date: 2020-01-03 (Fri, 03 Jan 2020)
Changed paths:
A llvm/test/CodeGen/AArch64/align-down.ll
A llvm/test/CodeGen/X86/align-down.ll
Log Message:
-----------
[NFC][DAGCombine][X86][AArch64] Tests for 'A - (A & (B - 1))' pattern (PR44448)
https://rise4fun.com/Alive/ZVdp
Name: ptr - (ptr & (alignment-1)) -> ptr & (0 - alignment)
%mask = add i64 %alignment, -1
%bias = and i64 %ptr, %mask
%r = sub i64 %ptr, %bias
=>
%highbitmask = sub i64 0, %alignment
%r = and i64 %ptr, %highbitmask
The main motivational pattern involes pointer-typed values,
so this transform can't really be done in middle-end.
See
https://bugs.llvm.org/show_bug.cgi?id=44448
https://reviews.llvm.org/D71499
Commit: 8dab0a4a7d691f2704f1079538e0ef29548db159
https://github.com/llvm/llvm-project/commit/8dab0a4a7d691f2704f1079538e0ef29548db159
Author: Roman Lebedev <lebedev.ri at gmail.com>
Date: 2020-01-03 (Fri, 03 Jan 2020)
Changed paths:
M llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
M llvm/test/CodeGen/AArch64/align-down.ll
M llvm/test/CodeGen/X86/align-down.ll
Log Message:
-----------
[DAGCombine][X86][AArch64] 'A - (A & (B - 1))' -> 'A & (0 - B)' 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.
https://rise4fun.com/Alive/ZVdp
Name: ptr - (ptr & (alignment-1)) -> ptr & (0 - alignment)
%mask = add i64 %alignment, -1
%bias = and i64 %ptr, %mask
%r = sub i64 %ptr, %bias
=>
%highbitmask = sub i64 0, %alignment
%r = and i64 %ptr, %highbitmask
See
https://bugs.llvm.org/show_bug.cgi?id=44448
https://reviews.llvm.org/D71499
Compare: https://github.com/llvm/llvm-project/compare/2e033244417c...8dab0a4a7d69
More information about the All-commits
mailing list