[RISCV] Support BSET/BCLR/BINV in hasAllWUsers.
authorCraig Topper <craig.topper@sifive.com>
Wed, 9 Nov 2022 19:16:00 +0000 (11:16 -0800)
committerCraig Topper <craig.topper@sifive.com>
Wed, 9 Nov 2022 19:32:20 +0000 (11:32 -0800)
These instructions set, clear, or invert a single bit. If their
users don't use the upper 32 bits, they don't use the upper 32 bits
of their input.

Additionally the second operand BSET/BCLR/BINV is a shift amount
which only uses 6 bits of the source.

Reviewed By: asb

Differential Revision: https://reviews.llvm.org/D137452

llvm/lib/Target/RISCV/RISCVSExtWRemoval.cpp

index 632f09c..d2e23a1 100644 (file)
@@ -139,6 +139,9 @@ static bool hasAllWUsers(const MachineInstr &OrigMI, MachineRegisterInfo &MRI) {
         break;
 
       case RISCV::SLL:
+      case RISCV::BSET:
+      case RISCV::BCLR:
+      case RISCV::BINV:
         // Operand 2 is the shift amount which uses 6 bits.
         if (OpIdx == 2)
           break;
@@ -199,6 +202,9 @@ static bool hasAllWUsers(const MachineInstr &OrigMI, MachineRegisterInfo &MRI) {
       case RISCV::SH2ADD:
       case RISCV::SH3ADD:
       case RISCV::XNOR:
+      case RISCV::BSETI:
+      case RISCV::BCLRI:
+      case RISCV::BINVI:
         Worklist.push_back(UserMI);
         break;
       }