Home | History | Annotate | Download | only in X86
      1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
      2 ; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s
      3 
      4 %struct.i = type { i32, i24 }
      5 %struct.m = type { %struct.i }
      6 
      7 @a = local_unnamed_addr global i32 0, align 4
      8 @b = local_unnamed_addr global i16 0, align 2
      9 @c = local_unnamed_addr global i16 0, align 2
     10 @e = local_unnamed_addr global i16 0, align 2
     11 @l = local_unnamed_addr global %struct.i zeroinitializer, align 4
     12 @k = local_unnamed_addr global %struct.m zeroinitializer, align 4
     13 
     14 @x0 = local_unnamed_addr global double 0.000000e+00, align 8
     15 @x1 = local_unnamed_addr global i32 0, align 4
     16 @x2 = local_unnamed_addr global i32 0, align 4
     17 @x3 = local_unnamed_addr global i32 0, align 4
     18 @x4 = local_unnamed_addr global i32 0, align 4
     19 @x5 = local_unnamed_addr global double* null, align 8
     20 
     21 ; Check that compiler does not crash.
     22 ; Test for PR30775
     23 define void @_Z1nv() local_unnamed_addr {
     24 ; CHECK-LABEL: _Z1nv:
     25 entry:
     26   %bf.load = load i32, i32* bitcast (i24* getelementptr inbounds (%struct.m, %struct.m* @k, i64 0, i32 0, i32 1) to i32*), align 4
     27   %0 = load i16, i16* @c, align 2
     28   %conv = sext i16 %0 to i32
     29   %1 = load i16, i16* @b, align 2
     30   %conv1 = sext i16 %1 to i32
     31   %2 = load i32, i32* @a, align 4
     32   %tobool = icmp ne i32 %2, 0
     33   %bf.load3 = load i32, i32* getelementptr inbounds (%struct.i, %struct.i* @l, i64 0, i32 0), align 4
     34   %bf.shl = shl i32 %bf.load3, 7
     35   %bf.ashr = ashr exact i32 %bf.shl, 7
     36   %bf.clear = shl i32 %bf.load, 1
     37   %factor = and i32 %bf.clear, 131070
     38   %add13 = add nsw i32 %factor, %conv
     39   %add15 = add nsw i32 %add13, %conv1
     40   %bf.ashr.op = sub nsw i32 0, %bf.ashr
     41   %add28 = select i1 %tobool, i32 %bf.ashr.op, i32 0
     42   %tobool29 = icmp eq i32 %add15, %add28
     43   %phitmp = icmp eq i32 %bf.ashr, 0
     44   %.phitmp = or i1 %phitmp, %tobool29
     45   %conv37 = zext i1 %.phitmp to i16
     46   store i16 %conv37, i16* @e, align 2
     47   %bf.clear39 = and i32 %bf.load, 65535
     48   %factor53 = shl nuw nsw i32 %bf.clear39, 1
     49   %add46 = add nsw i32 %factor53, %conv
     50   %add48 = add nsw i32 %add46, %conv1
     51   %add48.lobit = lshr i32 %add48, 31
     52   %add48.lobit.not = xor i32 %add48.lobit, 1
     53   %add51 = add nuw nsw i32 %add48.lobit.not, %bf.clear39
     54   %shr = ashr i32 %2, %add51
     55   %conv52 = trunc i32 %shr to i16
     56   store i16 %conv52, i16* @b, align 2
     57   ret void
     58 }
     59 
     60 ; Test for PR31536
     61 define void @_Z2x6v() local_unnamed_addr {
     62 ; CHECK-LABEL: _Z2x6v:
     63 entry:
     64   %0 = load i32, i32* @x1, align 4
     65   %and = and i32 %0, 511
     66   %add = add nuw nsw i32 %and, 1
     67   store i32 %add, i32* @x4, align 4
     68   %.pr = load i32, i32* @x3, align 4
     69   %tobool8 = icmp eq i32 %.pr, 0
     70   br i1 %tobool8, label %for.end5, label %for.cond1thread-pre-split.lr.ph
     71 
     72 for.cond1thread-pre-split.lr.ph:                  ; preds = %entry
     73   %idx.ext13 = zext i32 %add to i64
     74   %x5.promoted = load double*, double** @x5, align 8
     75   %x5.promoted9 = bitcast double* %x5.promoted to i8*
     76   %1 = xor i32 %.pr, -1
     77   %2 = zext i32 %1 to i64
     78   %3 = shl nuw nsw i64 %2, 3
     79   %4 = add nuw nsw i64 %3, 8
     80   %5 = mul nuw nsw i64 %4, %idx.ext13
     81   %uglygep = getelementptr i8, i8* %x5.promoted9, i64 %5
     82   %.pr6.pre = load i32, i32* @x2, align 4
     83   %6 = shl nuw nsw i32 %and, 3
     84   %addconv = add nuw nsw i32 %6, 8
     85   %7 = zext i32 %addconv to i64
     86   %scevgep15 = getelementptr double, double* %x5.promoted, i64 1
     87   %scevgep1516 = bitcast double* %scevgep15 to i8*
     88   br label %for.cond1thread-pre-split
     89 
     90 for.cond1thread-pre-split:                        ; preds = %for.cond1thread-pre-split.lr.ph, %for.inc3
     91   %indvar = phi i64 [ 0, %for.cond1thread-pre-split.lr.ph ], [ %indvar.next, %for.inc3 ]
     92   %.pr6 = phi i32 [ %.pr6.pre, %for.cond1thread-pre-split.lr.ph ], [ %.pr611, %for.inc3 ]
     93   %8 = phi double* [ %x5.promoted, %for.cond1thread-pre-split.lr.ph ], [ %add.ptr, %for.inc3 ]
     94   %9 = phi i32 [ %.pr, %for.cond1thread-pre-split.lr.ph ], [ %inc4, %for.inc3 ]
     95   %10 = mul i64 %7, %indvar
     96   %uglygep14 = getelementptr i8, i8* %x5.promoted9, i64 %10
     97   %uglygep17 = getelementptr i8, i8* %scevgep1516, i64 %10
     98   %cmp7 = icmp slt i32 %.pr6, 0
     99   br i1 %cmp7, label %for.body2.preheader, label %for.inc3
    100 
    101 for.body2.preheader:                              ; preds = %for.cond1thread-pre-split
    102   %11 = sext i32 %.pr6 to i64
    103   %12 = sext i32 %.pr6 to i64
    104   %13 = icmp sgt i64 %12, -1
    105   %smax = select i1 %13, i64 %12, i64 -1
    106   %14 = add nsw i64 %smax, 1
    107   %15 = sub nsw i64 %14, %12
    108   %min.iters.check = icmp ult i64 %15, 4
    109   br i1 %min.iters.check, label %for.body2.preheader21, label %min.iters.checked
    110 
    111 min.iters.checked:                                ; preds = %for.body2.preheader
    112   %n.vec = and i64 %15, -4
    113   %cmp.zero = icmp eq i64 %n.vec, 0
    114   br i1 %cmp.zero, label %for.body2.preheader21, label %vector.memcheck
    115 
    116 vector.memcheck:                                  ; preds = %min.iters.checked
    117   %16 = shl nsw i64 %11, 3
    118   %scevgep = getelementptr i8, i8* %uglygep14, i64 %16
    119   %17 = icmp sgt i64 %11, -1
    120   %smax18 = select i1 %17, i64 %11, i64 -1
    121   %18 = shl nsw i64 %smax18, 3
    122   %scevgep19 = getelementptr i8, i8* %uglygep17, i64 %18
    123   %bound0 = icmp ult i8* %scevgep, bitcast (double* @x0 to i8*)
    124   %bound1 = icmp ugt i8* %scevgep19, bitcast (double* @x0 to i8*)
    125   %memcheck.conflict = and i1 %bound0, %bound1
    126   %ind.end = add nsw i64 %11, %n.vec
    127   br i1 %memcheck.conflict, label %for.body2.preheader21, label %vector.body.preheader
    128 
    129 vector.body.preheader:                            ; preds = %vector.memcheck
    130   %19 = add nsw i64 %n.vec, -4
    131   %20 = lshr exact i64 %19, 2
    132   %21 = and i64 %20, 1
    133   %lcmp.mod = icmp eq i64 %21, 0
    134   br i1 %lcmp.mod, label %vector.body.prol.preheader, label %vector.body.prol.loopexit.unr-lcssa
    135 
    136 vector.body.prol.preheader:                       ; preds = %vector.body.preheader
    137   br label %vector.body.prol
    138 
    139 vector.body.prol:                                 ; preds = %vector.body.prol.preheader
    140   %22 = load i64, i64* bitcast (double* @x0 to i64*), align 8
    141   %23 = insertelement <2 x i64> undef, i64 %22, i32 0
    142   %24 = shufflevector <2 x i64> %23, <2 x i64> undef, <2 x i32> zeroinitializer
    143   %25 = insertelement <2 x i64> undef, i64 %22, i32 0
    144   %26 = shufflevector <2 x i64> %25, <2 x i64> undef, <2 x i32> zeroinitializer
    145   %27 = getelementptr inbounds double, double* %8, i64 %11
    146   %28 = bitcast double* %27 to <2 x i64>*
    147   store <2 x i64> %24, <2 x i64>* %28, align 8
    148   %29 = getelementptr double, double* %27, i64 2
    149   %30 = bitcast double* %29 to <2 x i64>*
    150   store <2 x i64> %26, <2 x i64>* %30, align 8
    151   br label %vector.body.prol.loopexit.unr-lcssa
    152 
    153 vector.body.prol.loopexit.unr-lcssa:              ; preds = %vector.body.preheader, %vector.body.prol
    154   %index.unr.ph = phi i64 [ 4, %vector.body.prol ], [ 0, %vector.body.preheader ]
    155   br label %vector.body.prol.loopexit
    156 
    157 vector.body.prol.loopexit:                        ; preds = %vector.body.prol.loopexit.unr-lcssa
    158   %31 = icmp eq i64 %20, 0
    159   br i1 %31, label %middle.block, label %vector.body.preheader.new
    160 
    161 vector.body.preheader.new:                        ; preds = %vector.body.prol.loopexit
    162   %32 = load i64, i64* bitcast (double* @x0 to i64*), align 8
    163   %33 = insertelement <2 x i64> undef, i64 %32, i32 0
    164   %34 = shufflevector <2 x i64> %33, <2 x i64> undef, <2 x i32> zeroinitializer
    165   %35 = insertelement <2 x i64> undef, i64 %32, i32 0
    166   %36 = shufflevector <2 x i64> %35, <2 x i64> undef, <2 x i32> zeroinitializer
    167   %37 = load i64, i64* bitcast (double* @x0 to i64*), align 8
    168   %38 = insertelement <2 x i64> undef, i64 %37, i32 0
    169   %39 = shufflevector <2 x i64> %38, <2 x i64> undef, <2 x i32> zeroinitializer
    170   %40 = insertelement <2 x i64> undef, i64 %37, i32 0
    171   %41 = shufflevector <2 x i64> %40, <2 x i64> undef, <2 x i32> zeroinitializer
    172   br label %vector.body
    173 
    174 vector.body:                                      ; preds = %vector.body, %vector.body.preheader.new
    175   %index = phi i64 [ %index.unr.ph, %vector.body.preheader.new ], [ %index.next.1, %vector.body ]
    176   %42 = add i64 %11, %index
    177   %43 = getelementptr inbounds double, double* %8, i64 %42
    178   %44 = bitcast double* %43 to <2 x i64>*
    179   store <2 x i64> %34, <2 x i64>* %44, align 8
    180   %45 = getelementptr double, double* %43, i64 2
    181   %46 = bitcast double* %45 to <2 x i64>*
    182   store <2 x i64> %36, <2 x i64>* %46, align 8
    183   %index.next = add i64 %index, 4
    184   %47 = add i64 %11, %index.next
    185   %48 = getelementptr inbounds double, double* %8, i64 %47
    186   %49 = bitcast double* %48 to <2 x i64>*
    187   store <2 x i64> %39, <2 x i64>* %49, align 8
    188   %50 = getelementptr double, double* %48, i64 2
    189   %51 = bitcast double* %50 to <2 x i64>*
    190   store <2 x i64> %41, <2 x i64>* %51, align 8
    191   %index.next.1 = add i64 %index, 8
    192   %52 = icmp eq i64 %index.next.1, %n.vec
    193   br i1 %52, label %middle.block.unr-lcssa, label %vector.body
    194 
    195 middle.block.unr-lcssa:                           ; preds = %vector.body
    196   br label %middle.block
    197 
    198 middle.block:                                     ; preds = %vector.body.prol.loopexit, %middle.block.unr-lcssa
    199   %cmp.n = icmp eq i64 %15, %n.vec
    200   br i1 %cmp.n, label %for.cond1.for.inc3_crit_edge, label %for.body2.preheader21
    201 
    202 for.body2.preheader21:                            ; preds = %middle.block, %vector.memcheck, %min.iters.checked, %for.body2.preheader
    203   %indvars.iv.ph = phi i64 [ %11, %vector.memcheck ], [ %11, %min.iters.checked ], [ %11, %for.body2.preheader ], [ %ind.end, %middle.block ]
    204   br label %for.body2
    205 
    206 for.body2:                                        ; preds = %for.body2.preheader21, %for.body2
    207   %indvars.iv = phi i64 [ %indvars.iv.next, %for.body2 ], [ %indvars.iv.ph, %for.body2.preheader21 ]
    208   %53 = load i64, i64* bitcast (double* @x0 to i64*), align 8
    209   %arrayidx = getelementptr inbounds double, double* %8, i64 %indvars.iv
    210   %54 = bitcast double* %arrayidx to i64*
    211   store i64 %53, i64* %54, align 8
    212   %indvars.iv.next = add nsw i64 %indvars.iv, 1
    213   %cmp = icmp slt i64 %indvars.iv, -1
    214   br i1 %cmp, label %for.body2, label %for.cond1.for.inc3_crit_edge.loopexit
    215 
    216 for.cond1.for.inc3_crit_edge.loopexit:            ; preds = %for.body2
    217   br label %for.cond1.for.inc3_crit_edge
    218 
    219 for.cond1.for.inc3_crit_edge:                     ; preds = %for.cond1.for.inc3_crit_edge.loopexit, %middle.block
    220   %indvars.iv.next.lcssa = phi i64 [ %ind.end, %middle.block ], [ %indvars.iv.next, %for.cond1.for.inc3_crit_edge.loopexit ]
    221   %55 = trunc i64 %indvars.iv.next.lcssa to i32
    222   store i32 %55, i32* @x2, align 4
    223   br label %for.inc3
    224 
    225 for.inc3:                                         ; preds = %for.cond1.for.inc3_crit_edge, %for.cond1thread-pre-split
    226   %.pr611 = phi i32 [ %55, %for.cond1.for.inc3_crit_edge ], [ %.pr6, %for.cond1thread-pre-split ]
    227   %inc4 = add nsw i32 %9, 1
    228   %add.ptr = getelementptr inbounds double, double* %8, i64 %idx.ext13
    229   %tobool = icmp eq i32 %inc4, 0
    230   %indvar.next = add i64 %indvar, 1
    231   br i1 %tobool, label %for.cond.for.end5_crit_edge, label %for.cond1thread-pre-split
    232 
    233 for.cond.for.end5_crit_edge:                      ; preds = %for.inc3
    234   store i8* %uglygep, i8** bitcast (double** @x5 to i8**), align 8
    235   store i32 0, i32* @x3, align 4
    236   br label %for.end5
    237 
    238 for.end5:                                         ; preds = %for.cond.for.end5_crit_edge, %entry
    239   ret void
    240 }
    241 
    242