[PATCH] D22122: [SCCP] Teach the pass about bitcasts

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 7 18:09:10 PDT 2016


davide added a comment.

I noticed that if I replace the call in visitCastInst() from ConstExpr::getCast() to ConstantFoldCastOperand() (as I used in my previous patch)

  diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp
  index d4c156e..346c121 100644
  --- a/lib/Transforms/Scalar/SCCP.cpp
  +++ b/lib/Transforms/Scalar/SCCP.cpp
  @@ -760,8 +760,9 @@ void SCCPSolver::visitCastInst(CastInst &I) {
     if (OpSt.isOverdefined())          // Inherit overdefinedness of operand
       markOverdefined(&I);
     else if (OpSt.isConstant()) {
  -    Constant *C =
  -        ConstantExpr::getCast(I.getOpcode(), OpSt.getConstant(), I.getType());
  +    Constant *C = ConstantFoldCastOperand(I.getOpcode(),
  +                                        getValueState(I.getOperand(0)).getConstant(),
  +                                        I.getType(), DL);
       if (isa<UndefValue>(C))
         return;
       // Propagate constant value

the value is actually folded. Is this is a reasonable change?


http://reviews.llvm.org/D22122





More information about the llvm-commits mailing list