[PATCH] D13008: Remove handling of AddrSpaceCast in stripAndAccumulateInBoundsConstantOffsets

Simon Cook via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 21 03:30:49 PDT 2015


simoncook created this revision.
simoncook added a subscriber: llvm-commits.

Unlike BitCasts, AddrSpaceCasts do not always produce an output the same size as its input, which was previously assumed. This fixes cases where two address spaces do not have the same size pointer, as an assertion failure would occur in LoopSimplify when an the output of an AddrSpaceCast is used as an input operand for a GEP as the base pointer would be of a different size to an offset.

http://reviews.llvm.org/D13008

Files:
  lib/IR/Value.cpp
  test/Transforms/LoopUnswitch/2015-09-18-Addrspace.ll

Index: test/Transforms/LoopUnswitch/2015-09-18-Addrspace.ll
===================================================================
--- /dev/null
+++ test/Transforms/LoopUnswitch/2015-09-18-Addrspace.ll
@@ -0,0 +1,19 @@
+; RUN: opt < %s -loop-unswitch -disable-output
+target datalayout = "e-m:e-p:16:16-p1:32:16-i32:16-i64:16-n8:16"
+
+define void @foo() {
+entry:
+  br i1 undef, label %for.body.i, label %bar.exit
+
+for.body.i:                                       ; preds = %for.body.i, %entry
+  %arrayidx.i1 = getelementptr inbounds i16, i16* undef, i16 undef
+  %arrayidx.i = addrspacecast i16* %arrayidx.i1 to i16 addrspace(1)*
+  %0 = load i16, i16 addrspace(1)* %arrayidx.i, align 2
+  %cmp1.i = icmp eq i16 %0, 0
+  %cmp1.i.not = xor i1 %cmp1.i, true
+  %brmerge = or i1 %cmp1.i.not, false
+  br i1 %brmerge, label %bar.exit, label %for.body.i
+
+bar.exit:                                         ; preds = %for.body.i, %entry
+  ret void
+}
Index: lib/IR/Value.cpp
===================================================================
--- lib/IR/Value.cpp
+++ lib/IR/Value.cpp
@@ -490,8 +490,7 @@
         return V;
       Offset = GEPOffset;
       V = GEP->getPointerOperand();
-    } else if (Operator::getOpcode(V) == Instruction::BitCast ||
-               Operator::getOpcode(V) == Instruction::AddrSpaceCast) {
+    } else if (Operator::getOpcode(V) == Instruction::BitCast) {
       V = cast<Operator>(V)->getOperand(0);
     } else if (GlobalAlias *GA = dyn_cast<GlobalAlias>(V)) {
       V = GA->getAliasee();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13008.35221.patch
Type: text/x-patch
Size: 1528 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150921/d0e8f1f5/attachment.bin>


More information about the llvm-commits mailing list