[PATCH] Fix shl folding in DAG combiner.

Paweł Bylica chfast at gmail.com
Mon Jun 22 09:02:52 PDT 2015


REPOSITORY
  rL LLVM

http://reviews.llvm.org/D10602

Files:
  llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/trunk/test/CodeGen/X86/fold-vector-shl-crash.ll

Index: llvm/trunk/test/CodeGen/X86/fold-vector-shl-crash.ll
===================================================================
--- llvm/trunk/test/CodeGen/X86/fold-vector-shl-crash.ll
+++ llvm/trunk/test/CodeGen/X86/fold-vector-shl-crash.ll
@@ -0,0 +1,8 @@
+; RUN: llc < %s | FileCheck %s
+
+;CHECK-LABEL: test
+define <2 x i256> @test() {
+  %S = shufflevector <2 x i256> zeroinitializer, <2 x i256> <i256 -1, i256 -1>, <2 x i32> <i32 0, i32 2>
+  %B = shl <2 x i256> %S, <i256 -1, i256 -1> ; DAG Combiner crashes here
+  ret <2 x i256> %B
+}
Index: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -4275,7 +4275,7 @@
   if (isNullConstant(N0))
     return N0;
   // fold (shl x, c >= size(x)) -> undef
-  if (N1C && N1C->getZExtValue() >= OpSizeInBits)
+  if (N1C && N1C->getAPIntValue().uge(OpSizeInBits))
     return DAG.getUNDEF(VT);
   // fold (shl x, 0) -> x
   if (N1C && N1C->isNullValue())

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10602.28118.patch
Type: text/x-patch
Size: 1087 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150622/9328d6bb/attachment.bin>


More information about the llvm-commits mailing list