From 896a885f215d8e3e2835b92274319771d358f313 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Mon, 4 Nov 2013 20:46:52 +0000 Subject: Fix another constant folding address space place I missed. This fixes an assertion failure with a different sized address space. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194014 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Transforms/InstCombine/constant-fold-gep.ll | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/Transforms/InstCombine/constant-fold-gep.ll b/test/Transforms/InstCombine/constant-fold-gep.ll index 9f82e66b38..5fb56023a4 100644 --- a/test/Transforms/InstCombine/constant-fold-gep.ll +++ b/test/Transforms/InstCombine/constant-fold-gep.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -instcombine -S | FileCheck %s -target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64" +target datalayout = "E-p:64:64:64-p1:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64" ; Constant folding should fix notionally out-of-bounds indices ; and add inbounds keywords. @@ -72,3 +72,21 @@ entry: ret i64 %E ; CHECK: ret i64 1000 } + +@X_as1 = addrspace(1) global [1000 x i8] zeroinitializer, align 16 + +define i16 @test2_as1() { +; CHECK-LABEL: @test2_as1( + ; CHECK: ret i16 1000 + +entry: + %A = bitcast i8 addrspace(1)* getelementptr inbounds ([1000 x i8] addrspace(1)* @X_as1, i64 1, i64 0) to i8 addrspace(1)* + %B = bitcast i8 addrspace(1)* getelementptr inbounds ([1000 x i8] addrspace(1)* @X_as1, i64 0, i64 0) to i8 addrspace(1)* + + %B2 = ptrtoint i8 addrspace(1)* %B to i16 + %C = sub i16 0, %B2 + %D = getelementptr i8 addrspace(1)* %A, i16 %C + %E = ptrtoint i8 addrspace(1)* %D to i16 + + ret i16 %E +} -- cgit v1.2.3