[llvm] r303802 - [DAG] Prevent crashes when merging constant stores with high-bit set. NFC.

Nirav Dave via llvm-commits llvm-commits at lists.llvm.org
Wed May 24 12:56:39 PDT 2017


Author: niravd
Date: Wed May 24 14:56:39 2017
New Revision: 303802

URL: http://llvm.org/viewvc/llvm-project?rev=303802&view=rev
Log:
[DAG] Prevent crashes when merging constant stores with high-bit set. NFC.

Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=303802&r1=303801&r2=303802&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Wed May 24 14:56:39 2017
@@ -12349,9 +12349,9 @@ bool DAGCombiner::MergeStoresOfConstants
       SDValue Val = St->getValue();
       StoreInt <<= ElementSizeBytes * 8;
       if (ConstantSDNode *C = dyn_cast<ConstantSDNode>(Val)) {
-        StoreInt |= C->getAPIntValue().zext(SizeInBits);
+        StoreInt |= C->getAPIntValue().zextOrTrunc(SizeInBits);
       } else if (ConstantFPSDNode *C = dyn_cast<ConstantFPSDNode>(Val)) {
-        StoreInt |= C->getValueAPF().bitcastToAPInt().zext(SizeInBits);
+        StoreInt |= C->getValueAPF().bitcastToAPInt().zextOrTrunc(SizeInBits);
       } else {
         llvm_unreachable("Invalid constant element type");
       }




More information about the llvm-commits mailing list