R E C U R S I O N I N L I N I N G I N L L V M - - PowerPoint PPT Presentation

r e c u r s i o n i n l i n i n g i n l l v m
SMART_READER_LITE
LIVE PREVIEW

R E C U R S I O N I N L I N I N G I N L L V M - - PowerPoint PPT Presentation

R E C U R S I O N I N L I N I N G I N L L V M P a b l o B a r r i o , A R M C h a n d l e r C a r r u t h , G o o g l e J a m e s M o l l o y , A R M Wh y ? Performance


slide-1
SLIDE 1

R E C U R S I O N I N L I N I N G I N L L V M

P a b l

  • B

a r r i

  • ,

A R M C h a n d l e r C a r r u t h , G

  • g

l e J a m e s M

  • l

l

  • y

, A R M

slide-2
SLIDE 2

Wh y ?

  • Performance improvements observed of up to ~20%.
  • Potentially improve chances for other optimization passes:
  • Increase function size.
  • Increase knowledge of the context.
  • Current status:
  • GCC inlines recursive function calls up to a certain depth.
  • LLVM marks recursive functions as noinline.
  • Code size and register pressure must be controlled.
slide-3
SLIDE 3

# 1 I n l i n e i t e r a t i v e l y

f(x): if x == 0 return 1 a = g(x) b = f(a) return a + h(b) f(x): if x == 0 return 1 a = g(x) if a == 0 b = 1 else: a1 = g(a) b1 = f(a1) b = a1 + h(b1) return a + h(b)

L e v e l 1 i n l i n e

slide-4
SLIDE 4

# 2 R e m

  • v

e r e c u r s i

  • n

w i t h a s t a c k

f(x): if x == 0 return 1 a = g(x) b = f(a) return a + h(b) f(x): x1 = x while x1 != 0: a = g(x) x1 = a push(a) b = 1 while S not empty: a = pop() b = a + h(b) return b a i s l i v e

slide-5
SLIDE 5

F i b

  • n

a c c i

G C C C l a n g B a s e (

  • O

3 ) 1 . 1 . 9 7 S t a c k 2 . 5 3 1 . 1 9 I t e r a t i v e i n l i n i n g 1 . 1 . 4 G C C C l a n g B a s e (

  • O

3 ) 3 . 5 2 . 5 4 S t a c k 2 . 6 7 2 . 7 1 I t e r a t i v e i n l i n i n g 3 . 5 2 . 7 4

T i m e r e l a t i v e t

  • G

C C b a s e O b j e c t s i z e ( k B )