[llvm] r323866 - [SystemZ] Check the bitwidth before calling isInt/isUInt.
Jonas Paulsson via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 31 04:41:25 PST 2018
Author: jonpa
Date: Wed Jan 31 04:41:25 2018
New Revision: 323866
URL: http://llvm.org/viewvc/llvm-project?rev=323866&view=rev
Log:
[SystemZ] Check the bitwidth before calling isInt/isUInt.
Since these methods will assert if the integer does not fit into 64 bits,
it is necessary to do this check before calling them in
supportedAddressingMode().
Review: Ulrich Weigand.
Added:
llvm/trunk/test/CodeGen/SystemZ/loop-04.ll
Modified:
llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp
Modified: llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp?rev=323866&r1=323865&r2=323866&view=diff
==============================================================================
--- llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp Wed Jan 31 04:41:25 2018
@@ -634,7 +634,8 @@ supportedAddressingMode(Instruction *I,
if (SingleUser->getParent() == I->getParent()) {
if (isa<ICmpInst>(SingleUser)) {
if (auto *C = dyn_cast<ConstantInt>(SingleUser->getOperand(1)))
- if (isInt<16>(C->getSExtValue()) || isUInt<16>(C->getZExtValue()))
+ if (C->getBitWidth() <= 64 &&
+ (isInt<16>(C->getSExtValue()) || isUInt<16>(C->getZExtValue())))
// Comparison of memory with 16 bit signed / unsigned immediate
return AddressingMode(false/*LongDispl*/, false/*IdxReg*/);
} else if (isa<StoreInst>(SingleUser))
Added: llvm/trunk/test/CodeGen/SystemZ/loop-04.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/SystemZ/loop-04.ll?rev=323866&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/SystemZ/loop-04.ll (added)
+++ llvm/trunk/test/CodeGen/SystemZ/loop-04.ll Wed Jan 31 04:41:25 2018
@@ -0,0 +1,25 @@
+; Test that SystemZISelLowering::supportedAddressingMode() does not crash on
+; a comparison of constant wider than 64 bits.
+;
+; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z13
+
+target datalayout = "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64"
+target triple = "s390x-ibm-linux"
+
+%0 = type <{ i64, [11 x i8] }>
+
+ at g_101 = external dso_local global <{ <{ i64, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 }>, <{ i64, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 }>, <{ i64, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 }>, <{ i64, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 }>, <{ i64, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 }>, <{ i64, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 }>, <{ i64, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 }>, <{ i64, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 }>, <{ i64, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 }>, <{ i64, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 }> }>, align 2
+
+; Function Attrs: nounwind
+define void @main() local_unnamed_addr #0 {
+ br label %1
+
+; <label>:1: ; preds = %1, %0
+ %2 = phi i64 [ 0, %0 ], [ %7, %1 ]
+ %3 = getelementptr inbounds [10 x %0], [10 x %0]* bitcast (<{ <{ i64, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 }>, <{ i64, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 }>, <{ i64, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 }>, <{ i64, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 }>, <{ i64, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 }>, <{ i64, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 }>, <{ i64, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 }>, <{ i64, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 }>, <{ i64, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 }>, <{ i64, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 }> }>* @g_101 to [10 x %0]*), i64 0, i64 %2, i32 1
+ %4 = bitcast [11 x i8]* %3 to i88*
+ %5 = load i88, i88* %4, align 1
+ %6 = icmp ult i88 %5, 2361183241434822606848
+ %7 = add nuw nsw i64 %2, 1
+ br label %1
+}
More information about the llvm-commits
mailing list