[PATCH] D14107: [SelectionDAG] Don't inspect !range metadata for extended loads

Sanjoy Das via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 27 17:36:02 PDT 2015


sanjoy updated this revision to Diff 38614.
sanjoy added a comment.

- add a test case


http://reviews.llvm.org/D14107

Files:
  lib/CodeGen/SelectionDAG/SelectionDAG.cpp
  test/CodeGen/PowerPC/selectiondag-extload-computeknownbits.ll

Index: test/CodeGen/PowerPC/selectiondag-extload-computeknownbits.ll
===================================================================
--- /dev/null
+++ test/CodeGen/PowerPC/selectiondag-extload-computeknownbits.ll
@@ -0,0 +1,12 @@
+; RUN: llc -mtriple=powerpc64-bgq-linux < %s
+
+; Check that llc does not crash due to an illegal APInt operation
+
+define i1 @f(i8* %ptr) {
+ entry:
+  %val = load i8, i8* %ptr, align 8, !range !0
+  %tobool = icmp eq i8 %val, 0
+  ret i1 %tobool
+}
+
+!0 = !{i8 0, i8 2}
Index: lib/CodeGen/SelectionDAG/SelectionDAG.cpp
===================================================================
--- lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -2284,7 +2284,8 @@
       unsigned MemBits = VT.getScalarType().getSizeInBits();
       KnownZero |= APInt::getHighBitsSet(BitWidth, BitWidth - MemBits);
     } else if (const MDNode *Ranges = LD->getRanges()) {
-      computeKnownBitsFromRangeMetadata(*Ranges, KnownZero);
+      if (LD->getExtensionType() == ISD::NON_EXTLOAD)
+        computeKnownBitsFromRangeMetadata(*Ranges, KnownZero);
     }
     break;
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14107.38614.patch
Type: text/x-patch
Size: 1138 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151028/9e6889f6/attachment.bin>


More information about the llvm-commits mailing list