summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 01ad8c3)
raw | patch | inline | side by side (parent: 01ad8c3)
author | Matt Arsenault <Matthew.Arsenault@amd.com> | |
Fri, 15 Nov 2013 05:45:08 +0000 (05:45 +0000) | ||
committer | Matt Arsenault <Matthew.Arsenault@amd.com> | |
Fri, 15 Nov 2013 05:45:08 +0000 (05:45 +0000) |
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194786 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/InstCombine/InstCombine.h | patch | blob | history | |
lib/Transforms/InstCombine/InstCombineCasts.cpp | patch | blob | history | |
test/Transforms/InstCombine/addrspacecast.ll | [new file with mode: 0644] | patch | blob |
index ee9510609e34d3003c56ca6e9b4a5b73ceba30b4..a5eddc206134a6632cf312b10388efb316f474f0 100644 (file)
Instruction *visitPtrToInt(PtrToIntInst &CI);
Instruction *visitIntToPtr(IntToPtrInst &CI);
Instruction *visitBitCast(BitCastInst &CI);
+ Instruction *visitAddrSpaceCast(AddrSpaceCastInst &CI);
Instruction *FoldSelectOpOp(SelectInst &SI, Instruction *TI,
Instruction *FI);
Instruction *FoldSelectIntoOp(SelectInst &SI, Value*, Value*);
diff --git a/lib/Transforms/InstCombine/InstCombineCasts.cpp b/lib/Transforms/InstCombine/InstCombineCasts.cpp
index 01894cbfdc157751bd25b813c396a047088a57fe..a1aedd4e8f1810c20ebc2532a440f18ed66cbac7 100644 (file)
return commonPointerCastTransforms(CI);
return commonCastTransforms(CI);
}
+
+Instruction *InstCombiner::visitAddrSpaceCast(AddrSpaceCastInst &CI) {
+ return commonCastTransforms(CI);
+}
diff --git a/test/Transforms/InstCombine/addrspacecast.ll b/test/Transforms/InstCombine/addrspacecast.ll
--- /dev/null
@@ -0,0 +1,31 @@
+; RUN: opt -instcombine -S < %s | FileCheck %s
+
+target datalayout = "e-p:64:64:64-p1:32:32:32-p2:16:16:16-n8:16:32:64"
+
+define i32* @combine_redundant_addrspacecast(i32 addrspace(1)* %x) nounwind {
+; CHECK-LABEL: @combine_redundant_addrspacecast(
+; CHECK: addrspacecast i32 addrspace(1)* %x to i32*
+; CHECK-NEXT: ret
+ %y = addrspacecast i32 addrspace(1)* %x to i32 addrspace(3)*
+ %z = addrspacecast i32 addrspace(3)* %y to i32*
+ ret i32* %z
+}
+
+define <4 x i32*> @combine_redundant_addrspacecast_vector(<4 x i32 addrspace(1)*> %x) nounwind {
+; CHECK-LABEL: @combine_redundant_addrspacecast_vector(
+; CHECK: addrspacecast <4 x i32 addrspace(1)*> %x to <4 x i32*>
+; CHECK-NEXT: ret
+ %y = addrspacecast <4 x i32 addrspace(1)*> %x to <4 x i32 addrspace(3)*>
+ %z = addrspacecast <4 x i32 addrspace(3)*> %y to <4 x i32*>
+ ret <4 x i32*> %z
+}
+
+define float* @combine_redundant_addrspacecast_types(i32 addrspace(1)* %x) nounwind {
+; CHECK-LABEL: @combine_redundant_addrspacecast_types(
+; CHECK: addrspacecast i32 addrspace(1)* %x to float*
+; CHECK-NEXT: ret
+ %y = addrspacecast i32 addrspace(1)* %x to i32 addrspace(3)*
+ %z = addrspacecast i32 addrspace(3)* %y to float*
+ ret float* %z
+}
+