[PATCH] [DAGCombiner] Fix & simplify constant folding of sext/zext.

Paweł Bylica chfast at gmail.com
Mon Jun 22 14:37:22 PDT 2015


================
Comment at: lib/CodeGen/SelectionDAG/DAGCombiner.cpp:5611
@@ -5613,4 +5610,3 @@
     if (Opcode == ISD::SIGN_EXTEND || Opcode == ISD::SIGN_EXTEND_VECTOR_INREG)
-      Elts.push_back(DAG.getConstant(C.shl(ShAmt).ashr(ShAmt).getZExtValue(),
-                                     DL, SVT));
+      Elts.push_back(DAG.getConstant(C.sextOrTrunc(VTBits), DL, SVT));
     else
----------------
RKSimon wrote:
> I think you need to just drop the 'getZExtValue()' and keep as a APInt:
> Elts.push_back(DAG.getConstant(C.shl(ShAmt).ashr(ShAmt), DL, SVT);
That's definitely safer change. But isn't it the same?

http://reviews.llvm.org/D10607

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list