Home | History | Annotate | Download | only in IndVarSimplify
      1 ; RUN: opt < %s -indvars -S > %t
      2 ; Exactly one getelementptr for each load+store.
      3 ; RUN: grep getelementptr %t | count 6
      4 ; Each getelementptr using %struct.Q* %s as a base and not i8*.
      5 ; RUN: grep {getelementptr \[%\]struct\\.Q\\* \[%\]s,} %t | count 6
      6 ; No explicit integer multiplications!
      7 ; RUN: not grep {= mul} %t
      8 ; No i8* arithmetic or pointer casting anywhere!
      9 ; RUN: not grep {i8\\*} %t
     10 ; RUN: not grep bitcast %t
     11 ; RUN: not grep inttoptr %t
     12 ; RUN: not grep ptrtoint %t
     13 
     14 ; FIXME: This test should pass with or without TargetData. Until opt
     15 ; supports running tests without targetdata, just hardware this in.
     16 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n:32:64"
     17 
     18 %struct.Q = type { [10 x %struct.N] }
     19 %struct.N = type { %struct.S }
     20 %struct.S = type { [100 x double], [100 x double] }
     21 
     22 define void @foo(%struct.Q* %s, i64 %n) nounwind {
     23 entry:
     24   br label %bb1
     25 
     26 bb1:
     27   %i = phi i64 [ 2, %entry ], [ %i.next, %bb ]
     28   %j = phi i64 [ 0, %entry ], [ %j.next, %bb ]
     29   %t5 = icmp slt i64 %i, %n
     30   br i1 %t5, label %bb, label %return
     31 
     32 bb:
     33   %t0 = getelementptr inbounds %struct.Q* %s, i64 0, i32 0, i64 0, i32 0, i32 0, i64 %i
     34   %t1 = load double* %t0, align 8
     35   %t2 = fmul double %t1, 3.200000e+00
     36   %t3 = getelementptr inbounds %struct.Q* %s, i64 0, i32 0, i64 0, i32 0, i32 0, i64 %i
     37   store double %t2, double* %t3, align 8
     38 
     39   %s0 = getelementptr inbounds %struct.Q* %s, i64 13, i32 0, i64 7, i32 0, i32 1, i64 %i
     40   %s1 = load double* %s0, align 8
     41   %s2 = fmul double %s1, 3.200000e+00
     42   %s3 = getelementptr inbounds %struct.Q* %s, i64 13, i32 0, i64 7, i32 0, i32 1, i64 %i
     43   store double %s2, double* %s3, align 8
     44 
     45   %u0 = getelementptr inbounds %struct.Q* %s, i64 0, i32 0, i64 7, i32 0, i32 1, i64 %j
     46   %u1 = load double* %u0, align 8
     47   %u2 = fmul double %u1, 3.200000e+00
     48   %u3 = getelementptr inbounds %struct.Q* %s, i64 0, i32 0, i64 7, i32 0, i32 1, i64 %j
     49   store double %u2, double* %u3, align 8
     50 
     51   %v0 = getelementptr inbounds %struct.Q* %s, i64 0, i32 0, i64 0, i32 0, i32 1, i64 %i
     52   %v1 = load double* %v0, align 8
     53   %v2 = fmul double %v1, 3.200000e+00
     54   %v3 = getelementptr inbounds %struct.Q* %s, i64 0, i32 0, i64 0, i32 0, i32 1, i64 %i
     55   store double %v2, double* %v3, align 8
     56 
     57   %w0 = getelementptr inbounds %struct.Q* %s, i64 0, i32 0, i64 0, i32 0, i32 0, i64 %j
     58   %w1 = load double* %w0, align 8
     59   %w2 = fmul double %w1, 3.200000e+00
     60   %w3 = getelementptr inbounds %struct.Q* %s, i64 0, i32 0, i64 0, i32 0, i32 0, i64 %j
     61   store double %w2, double* %w3, align 8
     62 
     63   %x0 = getelementptr inbounds %struct.Q* %s, i64 0, i32 0, i64 3, i32 0, i32 0, i64 %i
     64   %x1 = load double* %x0, align 8
     65   %x2 = fmul double %x1, 3.200000e+00
     66   %x3 = getelementptr inbounds %struct.Q* %s, i64 0, i32 0, i64 3, i32 0, i32 0, i64 %i
     67   store double %x2, double* %x3, align 8
     68 
     69   %i.next = add i64 %i, 1
     70   %j.next = add i64 %j, 1
     71   br label %bb1
     72 
     73 return:
     74   ret void
     75 }
     76