[PATCH] D123043: [X86] Add XOR(X, MIN_SIGNED_VALUE) -> ADD(X, MIN_SIGNED_VALUE) isel patterns (PR52267)

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 4 09:41:56 PDT 2022


craig.topper added inline comments.


================
Comment at: llvm/lib/Target/X86/X86InstrCompiler.td:1521
+
+// If safe, we prefer to pattern match XOR with min_signed_value as ADD at isel time.
+// ADD can be 3-addressified into an LEA instruction to avoid copies.
----------------
I'm not sure the "If safe" is needed here. I think this was copied from or_is_add where "safe" meant checking known bits. Here you explicitly wrote min_signed_value so there's nothing additional to check.


================
Comment at: llvm/lib/Target/X86/X86InstrCompiler.td:1525
+def xor_is_add : PatFrag<(ops node:$lhs, node:$rhs), (xor node:$lhs, node:$rhs),[{
+  if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(N->getOperand(1))) {
+    return CN->isMinSignedValue();
----------------
Drop curly braces?

You could even write
```
ConstantSDNode *CN = dyn_cast<ConstantSDNode>(N->getOperand(1));
return CN && CN->isMinSignedValue()
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123043



More information about the llvm-commits mailing list