Skip to content

Instantly share code, notes, and snippets.

@pftbest
Created July 14, 2017 18:45
Show Gist options
  • Save pftbest/5b9fb3202d69654ca23da3abc5436c8a to your computer and use it in GitHub Desktop.
Save pftbest/5b9fb3202d69654ca23da3abc5436c8a to your computer and use it in GitHub Desktop.
$ ./llvm-build/bin/llc func.ll -debug-only=isel
=== foo
Initial selection DAG: BB#0 'foo:start'
SelectionDAG has 9 nodes:
t2: i16 = Constant<0>
t0: ch = EntryToken
t4: i32,ch = load<LD4[@bar](align=2)(dereferenceable)> t0, GlobalAddress:i16<i32* @bar> 0, undef:i16
t6: i32 = add t4, Constant:i32<1>
t7: ch = store<ST4[@bar](align=2)> t4:1, t6, GlobalAddress:i16<i32* @bar> 0, undef:i16
t8: ch = MSP430ISD::RET_FLAG t7
Optimized lowered selection DAG: BB#0 'foo:start'
SelectionDAG has 8 nodes:
t0: ch = EntryToken
t4: i32,ch = load<LD4[@bar](align=2)(dereferenceable)> t0, GlobalAddress:i16<i32* @bar> 0, undef:i16
t6: i32 = add t4, Constant:i32<1>
t7: ch = store<ST4[@bar](align=2)> t4:1, t6, GlobalAddress:i16<i32* @bar> 0, undef:i16
t8: ch = MSP430ISD::RET_FLAG t7
Type-legalized selection DAG: BB#0 'foo:start'
SelectionDAG has 15 nodes:
t0: ch = EntryToken
t11: i16,ch = load<LD2[@bar](dereferenceable)> t0, GlobalAddress:i16<i32* @bar> 0, undef:i16
t14: i16,ch = load<LD2[@bar+2](dereferenceable)> t0, GlobalAddress:i16<i32* @bar> + 2, undef:i16
t15: ch = TokenFactor t11:1, t14:1
t16: i16,glue = addc t11, Constant:i16<1>
t18: ch = store<ST2[@bar]> t15, t16, GlobalAddress:i16<i32* @bar> 0, undef:i16
t17: i16,glue = adde t14, Constant:i16<0>, t16:1
t19: ch = store<ST2[@bar+2]> t15, t17, GlobalAddress:i16<i32* @bar> + 2, undef:i16
t20: ch = TokenFactor t18, t19
t8: ch = MSP430ISD::RET_FLAG t20
Optimized type-legalized selection DAG: BB#0 'foo:start'
SelectionDAG has 17 nodes:
t0: ch = EntryToken
t11: i16,ch = load<LD2[@bar](dereferenceable)> t0, GlobalAddress:i16<i32* @bar> 0, undef:i16
t14: i16,ch = load<LD2[@bar+2](dereferenceable)> t0, GlobalAddress:i16<i32* @bar> + 2, undef:i16
t15: ch = TokenFactor t11:1, t14:1
t16: i16,glue = addc t11, Constant:i16<1>
t23: ch = store<ST2[@bar]> t11:1, t16, GlobalAddress:i16<i32* @bar> 0, undef:i16
t24: ch = TokenFactor t15, t23
t17: i16,glue = adde t14, Constant:i16<0>, t16:1
t21: ch = store<ST2[@bar+2]> t14:1, t17, GlobalAddress:i16<i32* @bar> + 2, undef:i16
t22: ch = TokenFactor t15, t21
t20: ch = TokenFactor t24, t22
t8: ch = MSP430ISD::RET_FLAG t20
Legalized selection DAG: BB#0 'foo:start'
SelectionDAG has 19 nodes:
t0: ch = EntryToken
t11: i16,ch = load<LD2[@bar](dereferenceable)> t0, t28, undef:i16
t14: i16,ch = load<LD2[@bar+2](dereferenceable)> t0, t26, undef:i16
t16: i16,glue = addc t11, Constant:i16<1>
t15: ch = TokenFactor t11:1, t14:1
t26: i16 = MSP430ISD::Wrapper TargetGlobalAddress:i16<i32* @bar> + 2
t28: i16 = MSP430ISD::Wrapper TargetGlobalAddress:i16<i32* @bar> 0
t23: ch = store<ST2[@bar]> t11:1, t16, t28, undef:i16
t24: ch = TokenFactor t15, t23
t17: i16,glue = adde t14, Constant:i16<0>, t16:1
t21: ch = store<ST2[@bar+2]> t14:1, t17, t26, undef:i16
t22: ch = TokenFactor t15, t21
t20: ch = TokenFactor t24, t22
t8: ch = MSP430ISD::RET_FLAG t20
Optimized legalized selection DAG: BB#0 'foo:start'
SelectionDAG has 16 nodes:
t0: ch = EntryToken
t11: i16,ch = load<LD2[@bar](dereferenceable)> t0, t28, undef:i16
t14: i16,ch = load<LD2[@bar+2](dereferenceable)> t0, t26, undef:i16
t16: i16,glue = addc t11, Constant:i16<1>
t26: i16 = MSP430ISD::Wrapper TargetGlobalAddress:i16<i32* @bar> + 2
t28: i16 = MSP430ISD::Wrapper TargetGlobalAddress:i16<i32* @bar> 0
t23: ch = store<ST2[@bar]> t11:1, t16, t28, undef:i16
t17: i16,glue = adde t14, Constant:i16<0>, t16:1
t21: ch = store<ST2[@bar+2]> t14:1, t17, t26, undef:i16
t30: ch = TokenFactor t23, t21
t8: ch = MSP430ISD::RET_FLAG t30
===== Instruction selection begins: BB#0 'start'
ZZZ SelectCodeCommon, table size: 6348
ISEL: Starting pattern match on root node: t8: ch = MSP430ISD::RET_FLAG t30
Morphed node: t8: ch = RET t30
ISEL: Match complete!
ZZZ SelectCodeCommon, table size: 6348
ZZZ SelectCodeCommon, table size: 6348
ISEL: Starting pattern match on root node: t21: ch = store<ST2[@bar+2]> t14:1, t17, t26, undef:i16
Initial Opcode index to 5
OpcodeSwitch from 11 to 1062
Match failed at index 1084
Continuing at 1220
TypeSwitch[i16] from 1229 to 1259
Match failed at index 1260
Continuing at 1285
Match failed at index 1286
Continuing at 1311
Match failed at index 1315
Continuing at 1337
Continuing at 1338
Continuing at 1339
Match failed at index 1342
Continuing at 1406
Continuing at 3174
Match failed at index 3179
Continuing at 3228
Match failed at index 3229
Continuing at 3248
Morphed node: t21: ch = MOV16mr<Mem:ST2[@bar+2]> Register:i16 %noreg, TargetGlobalAddress:i16<i32* @bar> + 2, t17, t14:1
ISEL: Match complete!
ZZZ SelectCodeCommon, table size: 6348
ISEL: Starting pattern match on root node: t17: i16,glue = adde t14, Constant:i16<0>, t16:1
Initial Opcode index to 4741
Match failed at index 4746
Continuing at 4792
TypeSwitch[i16] from 4807 to 4826
Morphed node: t17: i16,i16,ch,glue = ADC16rm<Mem:LD2[@bar+2](dereferenceable)> Constant:i16<0>, Register:i16 %noreg, TargetGlobalAddress:i16<i32* @bar> + 2, t0, t16:1
ISEL: Match complete!
ZZZ SelectCodeCommon, table size: 6348
ISEL: Starting pattern match on root node: t23: ch = store<ST2[@bar]> t11:1, t16, t28, undef:i16
Initial Opcode index to 5
OpcodeSwitch from 11 to 2533
Match failed at index 2543
Continuing at 2809
Match failed at index 2812
Continuing at 2876
Continuing at 3174
Match failed at index 3179
Continuing at 3228
Match failed at index 3229
Continuing at 3248
Morphed node: t23: ch = MOV16mr<Mem:ST2[@bar]> Register:i16 %noreg, TargetGlobalAddress:i16<i32* @bar> 0, t16, t11:1
ISEL: Match complete!
ZZZ SelectCodeCommon, table size: 6348
ISEL: Starting pattern match on root node: t16: i16,glue = addc t11, Constant:i16<1>
Initial Opcode index to 5476
Match failed at index 5480
Continuing at 5526
TypeSwitch[i16] from 5541 to 5544
Morphed node: t16: i16,i16,ch,glue = ADD16rm<Mem:LD2[@bar](dereferenceable)> Constant:i16<1>, Register:i16 %noreg, TargetGlobalAddress:i16<i32* @bar> 0, t0
ISEL: Match complete!
ZZZ SelectCodeCommon, table size: 6348
ZZZ SelectCodeCommon, table size: 6348
ZZZ SelectCodeCommon, table size: 6348
ISEL: Starting pattern match on root node: t10: i16 = Constant<0>
Initial Opcode index to 6093
TypeSwitch[i16] from 6094 to 6108
Morphed node: t10: i16 = MOV16ri TargetConstant:i16<0>
ISEL: Match complete!
ZZZ SelectCodeCommon, table size: 6348
ISEL: Starting pattern match on root node: t9: i16 = Constant<1>
Initial Opcode index to 6093
TypeSwitch[i16] from 6094 to 6108
Morphed node: t9: i16 = MOV16ri TargetConstant:i16<1>
ISEL: Match complete!
ZZZ SelectCodeCommon, table size: 6348
===== Instruction selection ends:
Selected selection DAG: BB#0 'foo:start'
SelectionDAG has 14 nodes:
t0: ch = EntryToken
t9: i16 = MOV16ri TargetConstant:i16<1>
t16: i16,i16,ch,glue = ADD16rm<Mem:LD2[@bar](dereferenceable)> t9, Register:i16 %noreg, TargetGlobalAddress:i16<i32* @bar> 0, t0
t10: i16 = MOV16ri TargetConstant:i16<0>
t17: i16,i16,ch,glue = ADC16rm<Mem:LD2[@bar+2](dereferenceable)> t10, Register:i16 %noreg, TargetGlobalAddress:i16<i32* @bar> + 2, t0, t16:3
t23: ch = MOV16mr<Mem:ST2[@bar]> Register:i16 %noreg, TargetGlobalAddress:i16<i32* @bar> 0, t16, t16:2
t21: ch = MOV16mr<Mem:ST2[@bar+2]> Register:i16 %noreg, TargetGlobalAddress:i16<i32* @bar> + 2, t17, t17:2
t30: ch = TokenFactor t23, t21
t8: ch = RET t30
Total amount of phi nodes to update: 0
*** MachineFunction at end of ISel ***
# Machine code for function foo: IsSSA, TracksLiveness
BB#0: derived from LLVM BB %start
%vreg0<def> = MOV16ri 1; GR16:%vreg0
%vreg1<def> = MOV16ri 0; GR16:%vreg1
%vreg2<def,tied1> = ADD16rm %vreg0<tied0>, %noreg, <ga:@bar>, %SR<imp-def>; mem:LD2[@bar](dereferenceable) GR16:%vreg2,%vreg0
%vreg3<def,tied1> = ADC16rm %vreg1<tied0>, %noreg, <ga:@bar+2>, %SR<imp-def,dead>, %SR<imp-use>; mem:LD2[@bar+2](dereferenceable) GR16:%vreg3,%vreg1
MOV16mr %noreg, <ga:@bar+2>, %vreg3<kill>; mem:ST2[@bar+2] GR16:%vreg3
MOV16mr %noreg, <ga:@bar>, %vreg2<kill>; mem:ST2[@bar] GR16:%vreg2
RET
# End machine code for function foo.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment