1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-22 04:22:57 +02:00
llvm-mirror/test/Transforms/IndVarSimplify/preserve-gep-remainder.ll
Dan Gohman 0124c21ba0 Teach SCEVExpander to avoid creating over-indexed GEP indices when
possible. For example, it now emits

  %p.2.ip.1 = getelementptr [3 x [3 x double]]* %p, i64 2, i64 %tmp, i64 1

instead of the equivalent but less obvious

  %p.2.ip.1 = getelementptr [3 x [3 x double]]* %p, i64 0, i64 %tmp, i64 19

llvm-svn: 72452
2009-05-27 02:00:53 +00:00

20 lines
656 B
LLVM

; RUN: llvm-as < %s | opt -indvars | llvm-dis \
; RUN: | grep {\[%\]p.2.ip.1 = getelementptr \\\[3 x \\\[3 x double\\\]\\\]\\* \[%\]p, i64 2, i64 \[%\]tmp, i64 1}
; Indvars shouldn't expand this to
; %p.2.ip.1 = getelementptr [3 x [3 x double]]* %p, i64 0, i64 %tmp, i64 19
; or something. That's valid, but more obscure.
define void @foo([3 x [3 x double]]* noalias %p) nounwind {
entry:
br label %loop
loop:
%i = phi i64 [ 0, %entry ], [ %i.next, %loop ]
%ip = add i64 %i, 1
%p.2.ip.1 = getelementptr [3 x [3 x double]]* %p, i64 2, i64 %ip, i64 1
volatile store double 0.0, double* %p.2.ip.1
%i.next = add i64 %i, 1
br label %loop
}