[llvm-commits] [llvm] r159501 - /llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp

Craig Topper craig.topper at gmail.com
Sat Jun 30 19:17:08 PDT 2012


Author: ctopper
Date: Sat Jun 30 21:17:08 2012
New Revision: 159501

URL: http://llvm.org/viewvc/llvm-project?rev=159501&view=rev
Log:
Fix a crash on release builds if gather intrinsics are passed a non-constant value for the last argument.

Modified:
    llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp

Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp?rev=159501&r1=159500&r2=159501&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Sat Jun 30 21:17:08 2012
@@ -1963,7 +1963,8 @@
   SDValue VIdx = Node->getOperand(4);
   SDValue VMask = Node->getOperand(5);
   ConstantSDNode *Scale = dyn_cast<ConstantSDNode>(Node->getOperand(6));
-  assert(Scale && "Scale should be a constant for GATHER operations");
+  if (!Scale)
+    return 0;
 
   // Memory Operands: Base, Scale, Index, Disp, Segment
   SDValue Disp = CurDAG->getTargetConstant(0, MVT::i32);
@@ -2031,7 +2032,9 @@
       case Intrinsic::x86_avx2_gather_q_d:      Opc = X86::VPGATHERQDrm;  break;
       case Intrinsic::x86_avx2_gather_q_d_256:  Opc = X86::VPGATHERQDYrm; break;
       }
-      return SelectGather(Node, Opc);
+      SDNode *RetVal = SelectGather(Node, Opc);
+      if (RetVal)
+        return RetVal;
     }
     }
     break;





More information about the llvm-commits mailing list