[llvm] r213030 - Teach computeKnownBits to look through addrspacecast.
Matt Arsenault
Matthew.Arsenault at amd.com
Mon Jul 14 18:55:03 PDT 2014
Author: arsenm
Date: Mon Jul 14 20:55:03 2014
New Revision: 213030
URL: http://llvm.org/viewvc/llvm-project?rev=213030&view=rev
Log:
Teach computeKnownBits to look through addrspacecast.
This fixes inferring alignment through an addrspacecast.
Modified:
llvm/trunk/lib/Analysis/ValueTracking.cpp
llvm/trunk/test/Transforms/InstCombine/loadstore-alignment.ll
Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=213030&r1=213029&r2=213030&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ValueTracking.cpp (original)
+++ llvm/trunk/lib/Analysis/ValueTracking.cpp Mon Jul 14 20:55:03 2014
@@ -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, AP
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.
Modified: llvm/trunk/test/Transforms/InstCombine/loadstore-alignment.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/loadstore-alignment.ll?rev=213030&r1=213029&r2=213030&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/loadstore-alignment.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/loadstore-alignment.ll Mon Jul 14 20:55:03 2014
@@ -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
+ at 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) {
More information about the llvm-commits
mailing list