[polly] r251869 - [FIX] Use appropriately sized types for big constants
Johannes Doerfert via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 2 16:26:23 PST 2015
Author: jdoerfert
Date: Mon Nov 2 18:26:22 2015
New Revision: 251869
URL: http://llvm.org/viewvc/llvm-project?rev=251869&view=rev
Log:
[FIX] Use appropriately sized types for big constants
Added:
polly/trunk/test/Isl/CodeGen/large-numbers-in-boundary-context.ll
Modified:
polly/trunk/lib/CodeGen/IslExprBuilder.cpp
Modified: polly/trunk/lib/CodeGen/IslExprBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/IslExprBuilder.cpp?rev=251869&r1=251868&r2=251869&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/IslExprBuilder.cpp (original)
+++ polly/trunk/lib/CodeGen/IslExprBuilder.cpp Mon Nov 2 18:26:22 2015
@@ -639,7 +639,13 @@ Value *IslExprBuilder::createInt(__isl_t
Val = isl_ast_expr_get_val(Expr);
APValue = APIntFromVal(Val);
- T = getType(Expr);
+
+ auto BitWidth = APValue.getBitWidth();
+ if (BitWidth <= 64)
+ T = getType(Expr);
+ else
+ T = Builder.getIntNTy(BitWidth);
+
APValue = APValue.sextOrSelf(T->getBitWidth());
V = ConstantInt::get(T, APValue);
Added: polly/trunk/test/Isl/CodeGen/large-numbers-in-boundary-context.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/CodeGen/large-numbers-in-boundary-context.ll?rev=251869&view=auto
==============================================================================
--- polly/trunk/test/Isl/CodeGen/large-numbers-in-boundary-context.ll (added)
+++ polly/trunk/test/Isl/CodeGen/large-numbers-in-boundary-context.ll Mon Nov 2 18:26:22 2015
@@ -0,0 +1,56 @@
+; RUN: opt %loadPolly -S -polly-codegen < %s | FileCheck %s
+;
+; The boundary context contains a constant that does not fit in 64 bits. Hence,
+; we will check that we use an appropriaty typed constant, here with 65 bits.
+; An alternative would be to bail out early but that would not be as easy.
+;
+; CHECK: %13 = icmp sge i65 %12, -9223372036854775809
+;
+; CHECK: polly.start
+;
+target triple = "x86_64-unknown-linux-gnu"
+
+ at global = external global i32, align 4
+ at global1 = external global i32, align 4
+
+; Function Attrs: nounwind uwtable
+define void @hoge(i8* %arg) #0 {
+bb:
+ br label %bb5
+
+bb5: ; preds = %bb
+ %tmp = load i32, i32* @global, align 4
+ %tmp6 = sext i32 %tmp to i64
+ br label %bb11
+
+bb7: ; preds = %bb19
+ %tmp8 = load i32, i32* @global1, align 4
+ %tmp9 = sext i32 %tmp8 to i64
+ %tmp10 = icmp slt i64 %tmp13, %tmp9
+ br i1 %tmp10, label %bb11, label %bb20
+
+bb11: ; preds = %bb7, %bb5
+ %tmp12 = phi i64 [ %tmp6, %bb5 ], [ %tmp13, %bb7 ]
+ %tmp13 = add i64 %tmp12, 1
+ %tmp14 = getelementptr inbounds i8, i8* %arg, i64 %tmp13
+ %tmp15 = load i8, i8* %tmp14, align 1
+ br i1 false, label %bb16, label %bb17
+
+bb16: ; preds = %bb11
+ br label %bb18
+
+bb17: ; preds = %bb11
+ br label %bb18
+
+bb18: ; preds = %bb17, %bb16
+ br label %bb19
+
+bb19: ; preds = %bb19, %bb18
+ br i1 undef, label %bb19, label %bb7
+
+bb20: ; preds = %bb7
+ br label %bb21
+
+bb21: ; preds = %bb20
+ ret void
+}
More information about the llvm-commits
mailing list