Home | History | Annotate | Download | only in X86
      1 ; RUN: llc %s -mcpu=core2 -o - | FileCheck %s
      2 ; This test was failing while tracking the liveness in the register scavenger
      3 ; during the branching folding pass. The allocation of the subregisters was
      4 ; incorrect.
      5 ; I.e., the faulty pattern looked like:
      6 ; CH = movb 64
      7 ; ECX = movl 3 <- CH was killed here.
      8 ; CH = subb CH, ...
      9 ;
     10 ; This reduced test case triggers the crash before the fix, but does not
     11 ; strictly speaking check that the resulting code is correct.
     12 ; To check that the code is actually correct we would need to check the
     13 ; liveness of the produced code.
     14 ;
     15 ; Currently, we check that after ECX = movl 3, we do not have subb CH,
     16 ; whereas CH could have been redefine in between and that would have been
     17 ; totally fine.
     18 ; <rdar://problem/16582185>
     19 target datalayout = "e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128"
     20 target triple = "i386-apple-macosx10.9"
     21 
     22 %struct.A = type { %struct.B, %struct.C, %struct.D*, [1 x i8*] }
     23 %struct.B = type { i32, [4 x i8] }
     24 %struct.C = type { i128 }
     25 %struct.D = type { {}*, [0 x i32] }
     26 %union.E = type { i32 }
     27 
     28 ; CHECK-LABEL: __XXX1:
     29 ; CHECK: movl $3, %ecx
     30 ; CHECK-NOT: subb %{{[a-z]+}}, %ch
     31 ; Function Attrs: nounwind optsize ssp
     32 define fastcc void @__XXX1(%struct.A* %ht) #0 {
     33 entry:
     34   %const72 = bitcast i128 72 to i128
     35   %const3 = bitcast i128 3 to i128
     36   switch i32 undef, label %if.end196 [
     37     i32 1, label %sw.bb.i
     38     i32 3, label %sw.bb2.i
     39   ]
     40 
     41 sw.bb.i:                                          ; preds = %entry
     42   %call.i.i.i = tail call i32 undef(%struct.A* %ht, i8 zeroext 22, i32 undef, i32 0, %struct.D* undef)
     43   %bf.load.i.i = load i128, i128* undef, align 4
     44   %bf.lshr.i.i = lshr i128 %bf.load.i.i, %const72
     45   %shl1.i.i = shl nuw nsw i128 %bf.lshr.i.i, 8
     46   %shl.i.i = trunc i128 %shl1.i.i to i32
     47   br i1 undef, label %cond.false10.i.i, label %__XXX2.exit.i.i
     48 
     49 __XXX2.exit.i.i:                    ; preds = %sw.bb.i
     50   %extract11.i.i.i = lshr i128 %bf.load.i.i, %const3
     51   %extract.t12.i.i.i = trunc i128 %extract11.i.i.i to i32
     52   %bf.cast7.i.i.i = and i32 %extract.t12.i.i.i, 3
     53   %arrayidx.i.i.i = getelementptr inbounds %struct.A, %struct.A* %ht, i32 0, i32 3, i32 %bf.cast7.i.i.i
     54   br label %cond.end12.i.i
     55 
     56 cond.false10.i.i:                                 ; preds = %sw.bb.i
     57   %arrayidx.i6.i.i = getelementptr inbounds %struct.A, %struct.A* %ht, i32 0, i32 3, i32 0
     58   br label %cond.end12.i.i
     59 
     60 cond.end12.i.i:                                   ; preds = %cond.false10.i.i, %__XXX2.exit.i.i
     61   %.sink.in.i.i = phi i8** [ %arrayidx.i.i.i, %__XXX2.exit.i.i ], [ %arrayidx.i6.i.i, %cond.false10.i.i ]
     62   %.sink.i.i = load i8*, i8** %.sink.in.i.i, align 4
     63   %tmp = bitcast i8* %.sink.i.i to %union.E*
     64   br i1 undef, label %for.body.i.i, label %if.end196
     65 
     66 for.body.i.i:                                     ; preds = %for.body.i.i, %cond.end12.i.i
     67   %weak.i.i = getelementptr inbounds %union.E, %union.E* %tmp, i32 undef, i32 0
     68   %tmp1 = load i32, i32* %weak.i.i, align 4
     69   %cmp36.i.i = icmp ne i32 %tmp1, %shl.i.i
     70   %or.cond = and i1 %cmp36.i.i, false
     71   br i1 %or.cond, label %for.body.i.i, label %if.end196
     72 
     73 sw.bb2.i:                                         ; preds = %entry
     74   %bf.lshr.i85.i = lshr i128 undef, %const72
     75   br i1 undef, label %if.end196, label %__XXX2.exit.i95.i
     76 
     77 __XXX2.exit.i95.i:                  ; preds = %sw.bb2.i
     78   %extract11.i.i91.i = lshr i128 undef, %const3
     79   br label %if.end196
     80 
     81 if.end196:                                        ; preds = %__XXX2.exit.i95.i, %sw.bb2.i, %for.body.i.i, %cond.end12.i.i, %entry
     82   ret void
     83 }
     84 
     85 attributes #0 = { nounwind optsize ssp "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" }
     86