[llvm] 2053070 - [SCCP] remove unnecessary check for constant when folding sext->zext

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 30 14:26:24 PDT 2022


Author: Sanjay Patel
Date: 2022-09-30T17:26:10-04:00
New Revision: 20530704439666366b7f37e946c6f676ef0cc8c3

URL: https://github.com/llvm/llvm-project/commit/20530704439666366b7f37e946c6f676ef0cc8c3
DIFF: https://github.com/llvm/llvm-project/commit/20530704439666366b7f37e946c6f676ef0cc8c3.diff

LOG: [SCCP] remove unnecessary check for constant when folding sext->zext

I'm not sure how to test this because we seem to constant-fold
all examples already. We changed this code to use the common
isNonNegative() helper, so it should not be necessary to avoid
a constant. This makes the code uniform for all transforms.

Added: 
    

Modified: 
    llvm/lib/Transforms/Scalar/SCCP.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Scalar/SCCP.cpp b/llvm/lib/Transforms/Scalar/SCCP.cpp
index f6868cd70ce7..8f90c2b8ba1a 100644
--- a/llvm/lib/Transforms/Scalar/SCCP.cpp
+++ b/llvm/lib/Transforms/Scalar/SCCP.cpp
@@ -178,7 +178,7 @@ static bool replaceSignedInst(SCCPSolver &Solver,
   case Instruction::SExt: {
     // If the source value is not negative, this is a zext.
     Value *Op0 = Inst.getOperand(0);
-    if (isa<Constant>(Op0) || InsertedValues.count(Op0) || !isNonNegative(Op0))
+    if (InsertedValues.count(Op0) || !isNonNegative(Op0))
       return false;
     NewInst = new ZExtInst(Op0, Inst.getType(), "", &Inst);
     break;


        


More information about the llvm-commits mailing list