• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# RUN: llc -run-pass simple-register-coalescing %s -o - | FileCheck %s
2--- |
3  target datalayout = "e-m:e-i64:64-n32:64"
4  target triple = "powerpc64le-unknown-linux-gnu"
5
6  @b = common dso_local local_unnamed_addr global i32 0, align 4
7  @d = common dso_local local_unnamed_addr global i32 0, align 4
8  @e = common dso_local local_unnamed_addr global i32* null, align 8
9  @c = common dso_local local_unnamed_addr global i32 0, align 4
10  @a = common dso_local local_unnamed_addr global [1 x i32] zeroinitializer, align 4
11
12  ; Function Attrs: norecurse nounwind
13  define dso_local signext i32 @copycrunset() local_unnamed_addr #0 {
14  entry:
15    %0 = load i32, i32* @b, align 4
16    %tobool3 = icmp eq i32 %0, 0
17    br i1 %tobool3, label %while.end, label %while.body.preheader
18
19  while.body.preheader:                             ; preds = %entry
20    %.pre = load i32, i32* @d, align 4
21    %tobool1 = icmp eq i32 %.pre, 0
22    br label %while.body
23
24  while.body:                                       ; preds = %land.end, %while.body.preheader
25    br i1 %tobool1, label %land.end, label %land.rhs
26
27  land.rhs:                                         ; preds = %while.body
28    %1 = load i32*, i32** @e, align 8
29    %2 = load i32, i32* %1, align 4
30    %idxprom = sext i32 %2 to i64
31    %arrayidx = getelementptr inbounds [1 x i32], [1 x i32]* @a, i64 0, i64 %idxprom
32    %3 = load i32, i32* %arrayidx, align 4
33    %tobool2 = icmp ne i32 %3, 0
34    br label %land.end
35
36  land.end:                                         ; preds = %land.rhs, %while.body
37    %4 = phi i1 [ false, %while.body ], [ %tobool2, %land.rhs ]
38    %land.ext = zext i1 %4 to i32
39    store i32 %land.ext, i32* @c, align 4
40    br label %while.body
41
42  while.end:                                        ; preds = %entry
43    ret i32 undef
44  }
45
46...
47---
48name:            copycrunset
49alignment:       16
50exposesReturnsTwice: false
51legalized:       false
52regBankSelected: false
53selected:        false
54failedISel:      false
55tracksRegLiveness: true
56hasWinCFI:       false
57registers:
58  - { id: 0, class: crbitrc, preferred-register: '' }
59  - { id: 1, class: crbitrc, preferred-register: '' }
60  - { id: 2, class: crbitrc, preferred-register: '' }
61  - { id: 3, class: g8rc_and_g8rc_nox0, preferred-register: '' }
62  - { id: 4, class: gprc, preferred-register: '' }
63  - { id: 5, class: crrc, preferred-register: '' }
64  - { id: 6, class: g8rc_and_g8rc_nox0, preferred-register: '' }
65  - { id: 7, class: gprc, preferred-register: '' }
66  - { id: 8, class: crrc, preferred-register: '' }
67  - { id: 9, class: crbitrc, preferred-register: '' }
68  - { id: 10, class: g8rc_and_g8rc_nox0, preferred-register: '' }
69  - { id: 11, class: g8rc_and_g8rc_nox0, preferred-register: '' }
70  - { id: 12, class: g8rc, preferred-register: '' }
71  - { id: 13, class: g8rc_and_g8rc_nox0, preferred-register: '' }
72  - { id: 14, class: g8rc_and_g8rc_nox0, preferred-register: '' }
73  - { id: 15, class: g8rc, preferred-register: '' }
74  - { id: 16, class: gprc, preferred-register: '' }
75  - { id: 17, class: crrc, preferred-register: '' }
76  - { id: 18, class: crbitrc, preferred-register: '' }
77  - { id: 19, class: gprc_and_gprc_nor0, preferred-register: '' }
78  - { id: 20, class: gprc_and_gprc_nor0, preferred-register: '' }
79  - { id: 21, class: gprc, preferred-register: '' }
80  - { id: 22, class: g8rc_and_g8rc_nox0, preferred-register: '' }
81  - { id: 23, class: g8rc, preferred-register: '' }
82  - { id: 24, class: crbitrc, preferred-register: '' }
83liveins:
84  - { reg: '$x2', virtual-reg: '' }
85frameInfo:
86  isFrameAddressTaken: false
87  isReturnAddressTaken: false
88  hasStackMap:     false
89  hasPatchPoint:   false
90  stackSize:       0
91  offsetAdjustment: 0
92  maxAlignment:    0
93  adjustsStack:    false
94  hasCalls:        false
95  stackProtector:  ''
96  maxCallFrameSize: 4294967295
97  cvBytesOfCalleeSavedRegisters: 0
98  hasOpaqueSPAdjustment: false
99  hasVAStart:      false
100  hasMustTailInVarArgFunc: false
101  localFrameSize:  0
102  savePoint:       ''
103  restorePoint:    ''
104fixedStack:      []
105stack:           []
106constants:       []
107machineFunctionInfo: {}
108body:             |
109  bb.0.entry:
110    successors: %bb.5(0x30000000), %bb.1(0x50000000)
111    liveins: $x2
112
113    %3:g8rc_and_g8rc_nox0 = ADDIStocHA8 $x2, @b
114    %4:gprc = LWZ target-flags(ppc-toc-lo) @b, killed %3, implicit $x2 :: (dereferenceable load 4 from @b)
115    %5:crrc = CMPLWI killed %4, 0
116    BCC 76, killed %5, %bb.5
117    B %bb.1
118
119  bb.1.while.body.preheader:
120    successors: %bb.2(0x80000000)
121    liveins: $x2
122
123    %6:g8rc_and_g8rc_nox0 = ADDIStocHA8 $x2, @d
124    %7:gprc = LWZ target-flags(ppc-toc-lo) @d, killed %6, implicit $x2 :: (dereferenceable load 4 from @d)
125    %8:crrc = CMPWI killed %7, 0
126    %0:crbitrc = COPY killed %8.sub_eq
127    %9:crbitrc = CRUNSET
128    %19:gprc_and_gprc_nor0 = LI 0
129    %20:gprc_and_gprc_nor0 = LI 1
130    %22:g8rc_and_g8rc_nox0 = ADDIStocHA8 $x2, @c
131    %10:g8rc_and_g8rc_nox0 = ADDIStocHA8 $x2, @e
132    %13:g8rc_and_g8rc_nox0 = ADDIStocHA8 $x2, @a
133    %14:g8rc_and_g8rc_nox0 = ADDItocL killed %13, @a, implicit $x2
134
135  bb.2.while.body:
136    successors: %bb.4(0x30000000), %bb.3(0x50000000)
137    liveins: $x2
138
139    %24:crbitrc = COPY %9
140    BC %0, %bb.4
141    B %bb.3
142
143  bb.3.land.rhs:
144    successors: %bb.4(0x80000000)
145    liveins: $x2
146
147    %11:g8rc_and_g8rc_nox0 = LD target-flags(ppc-toc-lo) @e, %10, implicit $x2 :: (dereferenceable load 8 from @e)
148    %12:g8rc = LWA 0, killed %11 :: (load 4 from %ir.1)
149    %15:g8rc = RLDICR killed %12, 2, 61
150    %16:gprc = LWZX %14, killed %15 :: (load 4 from %ir.arrayidx)
151    %17:crrc = CMPWI killed %16, 0
152    %18:crbitrc = COPY killed %17.sub_eq
153    %1:crbitrc = CRNOR killed %18, %18
154    %24:crbitrc = COPY killed %1
155
156  bb.4.land.end:
157    successors: %bb.2(0x80000000)
158    liveins: $x2
159
160    %2:crbitrc = COPY killed %24
161    %21:gprc = ISEL %20, %19, killed %2
162    STW killed %21, target-flags(ppc-toc-lo) @c, %22, implicit $x2 :: (store 4 into @c)
163    B %bb.2
164
165  bb.5.while.end:
166    %23:g8rc = LI8 0
167    $x3 = COPY killed %23
168    BLR8 implicit $lr8, implicit $rm, implicit killed $x3
169
170...
171#Copy of CRUNSET should be removed in simple register coalescing pass
172#CHECK-LABEL: copycrunset
173#CHECK: bb.1.while.body.preheader:
174#CHECK-NOT: %9:crbitrc = CRUNSET
175#CHECK: bb.2.while.body:
176#CHECK-NOT: %24:crbitrc = COPY %9
177#CHECK: %24:crbitrc = CRUNSET
178#CHECK: B %bb.3
179