[PATCH] D140087: [X86] Replace (31/63 -/^ X) with (NOT X) and ignore (32/64 ^ X) when computing shift count

Phoebe Wang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 15 01:07:05 PST 2022


pengfei added a comment.

Pre-commit the test case and rebase to show the diff.



================
Comment at: llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:4005-4007
+      // If we are doing a NOT on just the lower bits with (Size*N-1) -/^ X
+      // we can replace it with a NOT. In the XOR case it may save some code
+      // size, in the SUB case it also may save a move.
----------------
The comments inside a different block look missleading. Should be moved inside the condition.


================
Comment at: llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:4011
+      assert(Add0C == nullptr || Add1C == nullptr);
+      assert(Add0C != nullptr || Add1C != nullptr);
+
----------------
Remove it. This cannot be false according to the if condition.


================
Comment at: llvm/test/CodeGen/X86/not-shift.ll:2
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=i686-unknown-linux-gnu -mattr=-bmi,-tbm,-bmi2 < %s | FileCheck %s --check-prefixes=X86-NOBMI2
+; RUN: llc -mtriple=i686-unknown-linux-gnu -mattr=+bmi,-tbm,-bmi2 < %s | FileCheck %s --check-prefixes=X86-NOBMI2
----------------
What's `tbm` used for. Seems it doesn't affect the result?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140087



More information about the llvm-commits mailing list