[llvm] 4e84149 - Revert "[RISCVGatherScatterLowering] Minor code cleanup [NFC]"

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Fri May 12 16:08:29 PDT 2023


Author: Philip Reames
Date: 2023-05-12T16:08:20-07:00
New Revision: 4e84149c0aea0e9f16c51cc92f50d90992b13d57

URL: https://github.com/llvm/llvm-project/commit/4e84149c0aea0e9f16c51cc92f50d90992b13d57
DIFF: https://github.com/llvm/llvm-project/commit/4e84149c0aea0e9f16c51cc92f50d90992b13d57.diff

LOG: Revert "[RISCVGatherScatterLowering] Minor code cleanup [NFC]"

This reverts commit 13984608992246e42e66c019f09764650d60af63.  A problem was reported - the attribution seems slightly questionable, but this is low enough value after 297e06c that reverting is easy.

Added: 
    

Modified: 
    llvm/lib/Target/RISCV/RISCVGatherScatterLowering.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/RISCV/RISCVGatherScatterLowering.cpp b/llvm/lib/Target/RISCV/RISCVGatherScatterLowering.cpp
index 5e527c60ca5f..ceefc261090b 100644
--- a/llvm/lib/Target/RISCV/RISCVGatherScatterLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVGatherScatterLowering.cpp
@@ -235,21 +235,16 @@ bool RISCVGatherScatterLowering::matchStridedRecurrence(Value *Index, Loop *L,
   if (!BO)
     return false;
 
-  switch (BO->getOpcode()) {
-  default:
+  if (BO->getOpcode() != Instruction::Add &&
+      BO->getOpcode() != Instruction::Or &&
+      BO->getOpcode() != Instruction::Mul &&
+      BO->getOpcode() != Instruction::Shl)
+    return false;
+
+  // We need to be able to treat Or as Add.
+  if (BO->getOpcode() == Instruction::Or &&
+      !haveNoCommonBitsSet(BO->getOperand(0), BO->getOperand(1), *DL))
     return false;
-  case Instruction::Or:
-    // We need to be able to treat Or as Add.
-    if (!haveNoCommonBitsSet(BO->getOperand(0), BO->getOperand(1), *DL))
-      return false;
-    break;
-  case Instruction::Add:
-    break;
-  case Instruction::Shl:
-    break;
-  case Instruction::Mul:
-    break;
-  }
 
   // We should have one operand in the loop and one splat.
   Value *OtherOp;
@@ -303,6 +298,7 @@ bool RISCVGatherScatterLowering::matchStridedRecurrence(Value *Index, Loop *L,
       Start = SplatOp;
     else
       Start = Builder.CreateAdd(Start, SplatOp, "start");
+    BasePtr->setIncomingValue(StartBlock, Start);
     break;
   }
   case Instruction::Mul: {
@@ -317,6 +313,8 @@ bool RISCVGatherScatterLowering::matchStridedRecurrence(Value *Index, Loop *L,
       Stride = SplatOp;
     else
       Stride = Builder.CreateMul(Stride, SplatOp, "stride");
+    Inc->setOperand(StepIndex, Step);
+    BasePtr->setIncomingValue(StartBlock, Start);
     break;
   }
   case Instruction::Shl: {
@@ -325,12 +323,12 @@ bool RISCVGatherScatterLowering::matchStridedRecurrence(Value *Index, Loop *L,
       Start = Builder.CreateShl(Start, SplatOp, "start");
     Step = Builder.CreateShl(Step, SplatOp, "step");
     Stride = Builder.CreateShl(Stride, SplatOp, "stride");
+    Inc->setOperand(StepIndex, Step);
+    BasePtr->setIncomingValue(StartBlock, Start);
     break;
   }
   }
 
-  Inc->setOperand(StepIndex, Step);
-  BasePtr->setIncomingValue(StartBlock, Start);
   return true;
 }
 


        


More information about the llvm-commits mailing list