[PATCH] D62263: [DAGCombine][X86][AArch64][AMDGPU] (x - y) + -1 -> add (xor y, -1), x fold

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 23 10:11:16 PDT 2019


lebedev.ri added inline comments.


================
Comment at: lib/CodeGen/SelectionDAG/DAGCombiner.cpp:2941
+  if (N0.hasOneUse() && N0.getOpcode() == ISD::SUB && isOneOrOneSplat(N1)) {
+    SDValue Xor = DAG.getNode(ISD::XOR, DL, VT, N0.getOperand(1), N1);
+    return DAG.getNode(ISD::ADD, DL, VT, Xor, N0.getOperand(0));
----------------
lebedev.ri wrote:
> RKSimon wrote:
> > N1 == 1 not -1 ?
> Uh, huh. I have no idea how i missed this.
I see what is going on.
I somehow copied it over from the one i'm adding to `visitADDLike()`, where it was correct, and did not notice.
The vector variant of `(sub x, c)` -> `(add x, (sub 0, c))` is almost ready to be posted..


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62263/new/

https://reviews.llvm.org/D62263





More information about the llvm-commits mailing list