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

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 29 11:47:00 PST 2022


lebedev.ri accepted this revision.
lebedev.ri added a comment.
This revision is now accepted and ready to land.

Please be sure to precommit the test changes before committing the change itself.
Looks good to me now. Thanks!



================
Comment at: llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:4023-4025
+      // ISelLowering will convert this to NOT already.
+      if (ConstValOp->isAllOnes())
+        return false;
----------------
Since we are already here, why not just do it ourselves?
That would be less LOC even.


================
Comment at: llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:4027
+
+      NewShiftAmt = CurDAG->getNOT(DL, Add0C == nullptr ? Add0 : Add1, OpVT);
+
----------------



================
Comment at: llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:4028
+      NewShiftAmt = CurDAG->getNOT(DL, Add0C == nullptr ? Add0 : Add1, OpVT);
+
+      insertDAGNode(*CurDAG, OrigShiftAmt, NewShiftAmt);
----------------
Remove newline


================
Comment at: llvm/test/CodeGen/X86/not-shift.ll:2-11
 ; RUN: llc -mtriple=i686-unknown-linux-gnu -mattr=-bmi,-bmi2 < %s | FileCheck %s --check-prefixes=X86-NOBMI2
 ; RUN: llc -mtriple=i686-unknown-linux-gnu -mattr=+bmi,-bmi2 < %s | FileCheck %s --check-prefixes=X86-NOBMI2
 ; RUN: llc -mtriple=i686-unknown-linux-gnu -mattr=+bmi,-bmi2 < %s | FileCheck %s --check-prefixes=X86-NOBMI2
 ; RUN: llc -mtriple=i686-unknown-linux-gnu -mattr=+bmi,+bmi2 < %s | FileCheck %s --check-prefixes=X86-BMI2
 ; RUN: llc -mtriple=i686-unknown-linux-gnu -mattr=+bmi,+bmi2 < %s | FileCheck %s --check-prefixes=X86-BMI2
 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mattr=-bmi,-bmi2 < %s | FileCheck %s --check-prefixes=X64-NOBMI2
 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mattr=+bmi,-bmi2 < %s | FileCheck %s --check-prefixes=X64-NOBMI2
----------------
Run lines are still wrong, please deduplicate them.
There should be only 4 i think?


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