This is definitely helpful on X86 where there is no subtract from an immediate instruction. So turning it into xor allows the immediate to fold.
Some of the PowerPC changes are regressions, but we may be able to fix them with other folds.
Paths
| Differential D48529
[DAGCombiner][X86][PowerPC][ARM][AMDGPU][Sparc] Replace (sub C, X) with (xor X, C) if there is no chance of a borrow during the subtraction. AbandonedPublic Authored by craig.topper on Jun 24 2018, 2:59 PM.
Details Summary This is definitely helpful on X86 where there is no subtract from an immediate instruction. So turning it into xor allows the immediate to fold. Some of the PowerPC changes are regressions, but we may be able to fix them with other folds.
Diff Detail
Event TimelineComment Actions Looks like a generally good fold to me - prefer bitwise logic because that's the cheapest ALU op possible. Adding some PowerPC reviewers to see if they're ok with the regression or if that must be fixed first.
Revision Contents
Diff 152618 lib/CodeGen/SelectionDAG/DAGCombiner.cpp
test/CodeGen/AMDGPU/ds-sub-offset.ll
test/CodeGen/ARM/intrinsics-overflow.ll
test/CodeGen/PowerPC/bool-math.ll
test/CodeGen/PowerPC/select_const.ll
test/CodeGen/SPARC/64bit.ll
test/CodeGen/X86/bool-math.ll
test/CodeGen/X86/dagcombine-select.ll
|
This is worse in terms of code size, so ideally there would be an undo-combine for this during selection