mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-15 09:33:39 +00:00
Teach computeKnownBits to look through addrspacecast.
This fixes inferring alignment through an addrspacecast. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213030 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e3c3920258
commit
832e3ffdb0
@ -29,6 +29,7 @@
|
||||
#include "llvm/IR/Metadata.h"
|
||||
#include "llvm/IR/Operator.h"
|
||||
#include "llvm/IR/PatternMatch.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
#include "llvm/Support/MathExtras.h"
|
||||
#include <cstring>
|
||||
using namespace llvm;
|
||||
@ -415,6 +416,7 @@ void llvm::computeKnownBits(Value *V, APInt &KnownZero, APInt &KnownOne,
|
||||
break; // Can't work with floating point.
|
||||
case Instruction::PtrToInt:
|
||||
case Instruction::IntToPtr:
|
||||
case Instruction::AddrSpaceCast: // Pointers could be different sizes.
|
||||
// We can't handle these if we don't know the pointer size.
|
||||
if (!TD) break;
|
||||
// FALL THROUGH and handle them the same as zext/trunc.
|
||||
|
@ -1,9 +1,11 @@
|
||||
; RUN: opt -instcombine -S < %s | FileCheck %s
|
||||
target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128"
|
||||
target datalayout = "E-p:64:64:64-p1:64:64:64-p2:32:32:32-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128"
|
||||
|
||||
@x = external global <2 x i64>, align 16
|
||||
@xx = external global [13 x <2 x i64>], align 16
|
||||
|
||||
@x.as2 = external addrspace(2) global <2 x i64>, align 16
|
||||
|
||||
; CHECK-LABEL: @static_hem(
|
||||
; CHECK: , align 16
|
||||
define <2 x i64> @static_hem() {
|
||||
@ -12,6 +14,33 @@ define <2 x i64> @static_hem() {
|
||||
ret <2 x i64> %tmp1
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @static_hem_addrspacecast(
|
||||
; CHECK: , align 16
|
||||
define <2 x i64> @static_hem_addrspacecast() {
|
||||
%t = getelementptr <2 x i64>* @x, i32 7
|
||||
%t.asc = addrspacecast <2 x i64>* %t to <2 x i64> addrspace(1)*
|
||||
%tmp1 = load <2 x i64> addrspace(1)* %t.asc, align 1
|
||||
ret <2 x i64> %tmp1
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @static_hem_addrspacecast_smaller_ptr(
|
||||
; CHECK: , align 16
|
||||
define <2 x i64> @static_hem_addrspacecast_smaller_ptr() {
|
||||
%t = getelementptr <2 x i64>* @x, i32 7
|
||||
%t.asc = addrspacecast <2 x i64>* %t to <2 x i64> addrspace(2)*
|
||||
%tmp1 = load <2 x i64> addrspace(2)* %t.asc, align 1
|
||||
ret <2 x i64> %tmp1
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @static_hem_addrspacecast_larger_ptr(
|
||||
; CHECK: , align 16
|
||||
define <2 x i64> @static_hem_addrspacecast_larger_ptr() {
|
||||
%t = getelementptr <2 x i64> addrspace(2)* @x.as2, i32 7
|
||||
%t.asc = addrspacecast <2 x i64> addrspace(2)* %t to <2 x i64> addrspace(1)*
|
||||
%tmp1 = load <2 x i64> addrspace(1)* %t.asc, align 1
|
||||
ret <2 x i64> %tmp1
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @hem(
|
||||
; CHECK: , align 16
|
||||
define <2 x i64> @hem(i32 %i) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user