Skip to content

Instantly share code, notes, and snippets.

@minglotus-6
Created April 21, 2022 08:09
Show Gist options
  • Save minglotus-6/39fb318886ae8deaf34a6f2f0d03fceb to your computer and use it in GitHub Desktop.
Save minglotus-6/39fb318886ae8deaf34a6f2f0d03fceb to your computer and use it in GitHub Desktop.
=== _Z3fooPlll
Creating new node: t2: i64,ch = CopyFromReg t0, Register:i64 %0
Creating new node: t4: i64,ch = CopyFromReg t0, Register:i64 %1
Creating new node: t6: i64,ch = CopyFromReg t0, Register:i64 %2
Creating constant: t7: i64 = Constant<0>
Creating new node: t8: i64 = undef
Creating new node: t9: i64,ch = load<(load (s64) from %ir.0)> t0, t2, undef:i64
Creating constant: t10: i64 = Constant<3>
Creating new node: t11: i64 = and t9, Constant:i64<3>
Creating new node: t13: i1 = setcc t11, Constant:i64<0>, seteq:ch
Creating new node: t14: i64 = select t13, t4, t6
Creating new node: t15: ch = store<(store (s64) into %ir.0)> t9:1, t14, t2, undef:i64
Creating constant: t16: i32 = TargetConstant<0>
Creating new node: t18: ch,glue = CopyToReg t15, Register:i64 $rax, t11
Creating new node: t19: ch = X86ISD::RET_FLAG t18, TargetConstant:i32<0>, Register:i64 $rax, t18:1
Initial selection DAG: %bb.0 '_Z3fooPlll:'
SelectionDAG has 20 nodes:
t0: ch = EntryToken
t2: i64,ch = CopyFromReg t0, Register:i64 %0
t9: i64,ch = load<(load (s64) from %ir.0)> t0, t2, undef:i64
t11: i64 = and t9, Constant:i64<3>
t13: i1 = setcc t11, Constant:i64<0>, seteq:ch
t4: i64,ch = CopyFromReg t0, Register:i64 %1
t6: i64,ch = CopyFromReg t0, Register:i64 %2
t14: i64 = select t13, t4, t6
t15: ch = store<(store (s64) into %ir.0)> t9:1, t14, t2, undef:i64
t18: ch,glue = CopyToReg t15, Register:i64 $rax, t11
t19: ch = X86ISD::RET_FLAG t18, TargetConstant:i32<0>, Register:i64 $rax, t18:1
Optimized lowered selection DAG: %bb.0 '_Z3fooPlll:'
SelectionDAG has 20 nodes:
t0: ch = EntryToken
t2: i64,ch = CopyFromReg t0, Register:i64 %0
t9: i64,ch = load<(load (s64) from %ir.0)> t0, t2, undef:i64
t11: i64 = and t9, Constant:i64<3>
t13: i1 = setcc t11, Constant:i64<0>, seteq:ch
t4: i64,ch = CopyFromReg t0, Register:i64 %1
t6: i64,ch = CopyFromReg t0, Register:i64 %2
t14: i64 = select t13, t4, t6
t15: ch = store<(store (s64) into %ir.0)> t9:1, t14, t2, undef:i64
t18: ch,glue = CopyToReg t15, Register:i64 $rax, t11
t19: ch = X86ISD::RET_FLAG t18, TargetConstant:i32<0>, Register:i64 $rax, t18:1
Creating new node: t20: i8 = setcc t11, Constant:i64<0>, seteq:ch
Creating new node: t21: i8 = zero_extend t13
Creating constant: t22: i8 = Constant<1>
Creating new node: t23: i8 = and t20, Constant:i8<1>
Type-legalized selection DAG: %bb.0 '_Z3fooPlll:'
SelectionDAG has 22 nodes:
t0: ch = EntryToken
t2: i64,ch = CopyFromReg t0, Register:i64 %0
t9: i64,ch = load<(load (s64) from %ir.0)> t0, t2, undef:i64
t11: i64 = and t9, Constant:i64<3>
t20: i8 = setcc t11, Constant:i64<0>, seteq:ch
t23: i8 = and t20, Constant:i8<1>
t4: i64,ch = CopyFromReg t0, Register:i64 %1
t6: i64,ch = CopyFromReg t0, Register:i64 %2
t14: i64 = select t23, t4, t6
t15: ch = store<(store (s64) into %ir.0)> t9:1, t14, t2, undef:i64
t18: ch,glue = CopyToReg t15, Register:i64 $rax, t11
t19: ch = X86ISD::RET_FLAG t18, TargetConstant:i32<0>, Register:i64 $rax, t18:1
Optimized type-legalized selection DAG: %bb.0 '_Z3fooPlll:'
SelectionDAG has 20 nodes:
t0: ch = EntryToken
t2: i64,ch = CopyFromReg t0, Register:i64 %0
t9: i64,ch = load<(load (s64) from %ir.0)> t0, t2, undef:i64
t11: i64 = and t9, Constant:i64<3>
t20: i8 = setcc t11, Constant:i64<0>, seteq:ch
t4: i64,ch = CopyFromReg t0, Register:i64 %1
t6: i64,ch = CopyFromReg t0, Register:i64 %2
t14: i64 = select t20, t4, t6
t15: ch = store<(store (s64) into %ir.0)> t9:1, t14, t2, undef:i64
t18: ch,glue = CopyToReg t15, Register:i64 $rax, t11
t19: ch = X86ISD::RET_FLAG t18, TargetConstant:i32<0>, Register:i64 $rax, t18:1
Legalizing: t19: ch = X86ISD::RET_FLAG t18, TargetConstant:i32<0>, Register:i64 $rax, t18:1
Legal node: nothing to do
Legalizing: t18: ch,glue = CopyToReg t15, Register:i64 $rax, t11
Legal node: nothing to do
Legalizing: t15: ch = store<(store (s64) into %ir.0)> t9:1, t14, t2, undef:i64
Legalizing store operation
Optimizing float store operations
Legal store
Legalizing: t14: i64 = select t20, t4, t6
Trying custom legalization
Creating new node: t24: i64,i32 = X86ISD::AND t9, Constant:i64<3>
Creating constant: t25: i8 = TargetConstant<4>
Creating new node: t26: i8 = X86ISD::SETCC TargetConstant:i8<4>, t24:1
Creating new node: t27: i64 = X86ISD::CMOV t6, t4, TargetConstant:i8<4>, t24:1
Successfully custom legalized node
... replacing: t14: i64 = select t20, t4, t6
with: t27: i64 = X86ISD::CMOV t6, t4, TargetConstant:i8<4>, t24:1
Legalizing: t9: i64,ch = load<(load (s64) from %ir.0)> t0, t2, undef:i64
Legalizing non-extending load operation
Legalizing: t6: i64,ch = CopyFromReg t0, Register:i64 %2
Legal node: nothing to do
Legalizing: t4: i64,ch = CopyFromReg t0, Register:i64 %1
Legal node: nothing to do
Legalizing: t2: i64,ch = CopyFromReg t0, Register:i64 %0
Legal node: nothing to do
Legalizing: t17: i64 = Register $rax
Legalizing: t16: i32 = TargetConstant<0>
Legalizing: t10: i64 = Constant<3>
Legal node: nothing to do
Legalizing: t8: i64 = undef
Legal node: nothing to do
Legalizing: t5: i64 = Register %2
Legalizing: t3: i64 = Register %1
Legalizing: t1: i64 = Register %0
Legalizing: t0: ch = EntryToken
Legal node: nothing to do
Legalizing: t27: i64 = X86ISD::CMOV t6, t4, TargetConstant:i8<4>, t24:1
Legal node: nothing to do
Legalizing: t25: i8 = TargetConstant<4>
Legalizing: t24: i64,i32 = X86ISD::AND t9, Constant:i64<3>
Legal node: nothing to do
Legalized selection DAG: %bb.0 '_Z3fooPlll:'
SelectionDAG has 18 nodes:
t0: ch = EntryToken
t2: i64,ch = CopyFromReg t0, Register:i64 %0
t9: i64,ch = load<(load (s64) from %ir.0)> t0, t2, undef:i64
t6: i64,ch = CopyFromReg t0, Register:i64 %2
t4: i64,ch = CopyFromReg t0, Register:i64 %1
t27: i64 = X86ISD::CMOV t6, t4, TargetConstant:i8<4>, t24:1
t15: ch = store<(store (s64) into %ir.0)> t9:1, t27, t2, undef:i64
t18: ch,glue = CopyToReg t15, Register:i64 $rax, t24
t24: i64,i32 = X86ISD::AND t9, Constant:i64<3>
t19: ch = X86ISD::RET_FLAG t18, TargetConstant:i32<0>, Register:i64 $rax, t18:1
Legalizing: t27: i64 = X86ISD::CMOV t6, t4, TargetConstant:i8<4>, t24:1
Legal node: nothing to do
Legalizing: t25: i8 = TargetConstant<4>
Legalizing: t24: i64,i32 = X86ISD::AND t9, Constant:i64<3>
Legal node: nothing to do
Legalizing: t19: ch = X86ISD::RET_FLAG t18, TargetConstant:i32<0>, Register:i64 $rax, t18:1
Legal node: nothing to do
Legalizing: t18: ch,glue = CopyToReg t15, Register:i64 $rax, t24
Legal node: nothing to do
Legalizing: t15: ch = store<(store (s64) into %ir.0)> t9:1, t27, t2, undef:i64
Legalizing store operation
Optimizing float store operations
Legal store
Legalizing: t9: i64,ch = load<(load (s64) from %ir.0)> t0, t2, undef:i64
Legalizing non-extending load operation
Legalizing: t6: i64,ch = CopyFromReg t0, Register:i64 %2
Legal node: nothing to do
Legalizing: t4: i64,ch = CopyFromReg t0, Register:i64 %1
Legal node: nothing to do
Legalizing: t2: i64,ch = CopyFromReg t0, Register:i64 %0
Legal node: nothing to do
Legalizing: t17: i64 = Register $rax
Legalizing: t16: i32 = TargetConstant<0>
Legalizing: t10: i64 = Constant<3>
Legal node: nothing to do
Legalizing: t8: i64 = undef
Legal node: nothing to do
Legalizing: t5: i64 = Register %2
Legalizing: t3: i64 = Register %1
Legalizing: t1: i64 = Register %0
Legalizing: t0: ch = EntryToken
Legal node: nothing to do
Optimized legalized selection DAG: %bb.0 '_Z3fooPlll:'
SelectionDAG has 18 nodes:
t0: ch = EntryToken
t2: i64,ch = CopyFromReg t0, Register:i64 %0
t9: i64,ch = load<(load (s64) from %ir.0)> t0, t2, undef:i64
t6: i64,ch = CopyFromReg t0, Register:i64 %2
t4: i64,ch = CopyFromReg t0, Register:i64 %1
t27: i64 = X86ISD::CMOV t6, t4, TargetConstant:i8<4>, t24:1
t15: ch = store<(store (s64) into %ir.0)> t9:1, t27, t2, undef:i64
t18: ch,glue = CopyToReg t15, Register:i64 $rax, t24
t24: i64,i32 = X86ISD::AND t9, Constant:i64<3>
t19: ch = X86ISD::RET_FLAG t18, TargetConstant:i32<0>, Register:i64 $rax, t18:1
===== Instruction selection begins: %bb.0 ''
ISEL: Starting selection on root node: t19: ch = X86ISD::RET_FLAG t18, TargetConstant:i32<0>, Register:i64 $rax, t18:1
ISEL: Starting pattern match
Morphed node: t19: ch = RET TargetConstant:i32<0>, Register:i64 $rax, t18, t18:1
ISEL: Match complete!
ISEL: Starting selection on root node: t18: ch,glue = CopyToReg t15, Register:i64 $rax, t24
ISEL: Starting selection on root node: t15: ch = store<(store (s64) into %ir.0)> t9:1, t27, t2, undef:i64
ISEL: Starting pattern match
Initial Opcode index to 6
Skipped scope entry (due to false predicate) at index 14, continuing at 81
Skipped scope entry (due to false predicate) at index 82, continuing at 149
Skipped scope entry (due to false predicate) at index 150, continuing at 199
Skipped scope entry (due to false predicate) at index 200, continuing at 249
Skipped scope entry (due to false predicate) at index 250, continuing at 317
Skipped scope entry (due to false predicate) at index 318, continuing at 367
Skipped scope entry (due to false predicate) at index 368, continuing at 394
Match failed at index 402
Continuing at 421
Match failed at index 422
Continuing at 471
Match failed at index 472
Continuing at 521
Match failed at index 522
Continuing at 571
Match failed at index 572
Continuing at 639
Match failed at index 640
Continuing at 707
Match failed at index 708
Continuing at 775
Match failed at index 776
Continuing at 804
Match failed at index 805
Continuing at 833
Match failed at index 834
Continuing at 862
Match failed at index 863
Continuing at 891
Match failed at index 892
Continuing at 920
Match failed at index 921
Continuing at 949
Match failed at index 950
Continuing at 987
Match failed at index 988
Continuing at 1025
Continuing at 1026
Match failed at index 1029
Continuing at 14206
Match failed at index 14210
Continuing at 15383
Match failed at index 15386
Continuing at 15982
Match failed at index 15983
Continuing at 16080
Match failed at index 16081
Continuing at 16178
Skipped scope entry (due to false predicate) at index 16184, continuing at 16301
Match failed at index 16304
Continuing at 16330
Match failed at index 16333
Continuing at 16359
Match failed at index 16362
Continuing at 16388
Match failed at index 16389
Continuing at 16419
Continuing at 16420
Match failed at index 16422
Continuing at 16503
Skipped scope entry (due to false predicate) at index 16508, continuing at 16590
Skipped scope entry (due to false predicate) at index 16591, continuing at 16699
Skipped scope entry (due to false predicate) at index 16700, continuing at 16769
Skipped scope entry (due to false predicate) at index 16770, continuing at 16792
Skipped scope entry (due to false predicate) at index 16793, continuing at 16815
Skipped scope entry (due to false predicate) at index 16816, continuing at 16838
MatchAddress: X86ISelAddressMode 0x7ffcbf693ae0
Base_Reg nul
Scale 1
IndexReg nul
Disp 0
GV nul CP nul
ES nul MCSym nul JT-1 Align1
Creating constant: t28: i8 = TargetConstant<1>
Morphed node: t15: ch = MOV64mr<Mem:(store (s64) into %ir.0)> t2, TargetConstant:i8<1>, Register:i64 $noreg, TargetConstant:i32<0>, Register:i16 $noreg, t27, t9:1
ISEL: Match complete!
ISEL: Starting selection on root node: t27: i64 = X86ISD::CMOV t6, t4, TargetConstant:i8<4>, t24:1
ISEL: Starting pattern match
Initial Opcode index to 76532
Match failed at index 76536
Continuing at 76652
Match failed at index 76655
Continuing at 76783
TypeSwitch[i64] from 76796 to 76867
Creating new node: t32: ch,glue = CopyToReg t0, Register:i32 $eflags, t24:1
Morphed node: t27: i64 = CMOV64rr t6, t4, TargetConstant:i8<4>, t32:1
ISEL: Match complete!
ISEL: Starting selection on root node: t24: i64,i32 = X86ISD::AND t9, Constant:i64<3>
ISEL: Starting pattern match
Initial Opcode index to 85510
OpcodeSwitch from 85514 to 85587
Match failed at index 85589
Continuing at 85662
Match failed at index 85665
Continuing at 85768
OpcodeSwitch from 85771 to 85775
Match failed at index 85777
Continuing at 86047
Match failed at index 86050
Continuing at 86159
Match failed at index 86161
Continuing at 86274
Match failed at index 86293
Continuing at 86306
Match failed at index 86312
Continuing at 86325
Match failed at index 86331
Continuing at 86344
Creating constant: t33: i64 = TargetConstant<3>
Morphed node: t24: i64,i32 = AND64ri8 t9, TargetConstant:i64<3>
ISEL: Match complete!
ISEL: Starting selection on root node: t9: i64,ch = load<(load (s64) from %ir.0)> t0, t2, undef:i64
ISEL: Starting pattern match
Initial Opcode index to 117171
Match failed at index 117180
Continuing at 117197
Match failed at index 117200
Continuing at 117217
Match failed at index 117220
Continuing at 117237
MatchAddress: X86ISelAddressMode 0x7ffcbf693ae0
Base_Reg nul
Scale 1
IndexReg nul
Disp 0
GV nul CP nul
ES nul MCSym nul JT-1 Align1
Morphed node: t9: i64,ch = MOV64rm<Mem:(load (s64) from %ir.0)> t2, TargetConstant:i8<1>, Register:i64 $noreg, TargetConstant:i32<0>, Register:i16 $noreg, t0
ISEL: Match complete!
ISEL: Starting selection on root node: t6: i64,ch = CopyFromReg t0, Register:i64 %2
ISEL: Starting selection on root node: t4: i64,ch = CopyFromReg t0, Register:i64 %1
ISEL: Starting selection on root node: t2: i64,ch = CopyFromReg t0, Register:i64 %0
ISEL: Starting selection on root node: t25: i8 = TargetConstant<4>
ISEL: Starting selection on root node: t17: i64 = Register $rax
ISEL: Starting selection on root node: t16: i32 = TargetConstant<0>
ISEL: Starting selection on root node: t5: i64 = Register %2
ISEL: Starting selection on root node: t3: i64 = Register %1
ISEL: Starting selection on root node: t1: i64 = Register %0
ISEL: Starting selection on root node: t0: ch = EntryToken
===== Instruction selection ends:
Selected selection DAG: %bb.0 '_Z3fooPlll:'
SelectionDAG has 22 nodes:
t0: ch = EntryToken
t2: i64,ch = CopyFromReg t0, Register:i64 %0
t9: i64,ch = MOV64rm<Mem:(load (s64) from %ir.0)> t2, TargetConstant:i8<1>, Register:i64 $noreg, TargetConstant:i32<0>, Register:i16 $noreg, t0
t24: i64,i32 = AND64ri8 t9, TargetConstant:i64<3>
t6: i64,ch = CopyFromReg t0, Register:i64 %2
t4: i64,ch = CopyFromReg t0, Register:i64 %1
t32: ch,glue = CopyToReg t0, Register:i32 $eflags, t24:1
t27: i64 = CMOV64rr t6, t4, TargetConstant:i8<4>, t32:1
t15: ch = MOV64mr<Mem:(store (s64) into %ir.0)> t2, TargetConstant:i8<1>, Register:i64 $noreg, TargetConstant:i32<0>, Register:i16 $noreg, t27, t9:1
t18: ch,glue = CopyToReg t15, Register:i64 $rax, t24
t19: ch = RET TargetConstant:i32<0>, Register:i64 $rax, t18, t18:1
Total amount of phi nodes to update: 0
*** MachineFunction at end of ISel ***
# Machine code for function _Z3fooPlll: IsSSA, TracksLiveness
Function Live Ins: $rdi in %0, $rsi in %1, $rdx in %2
bb.0 (%ir-block.3):
liveins: $rdi, $rsi, $rdx
%2:gr64 = COPY $rdx
%1:gr64 = COPY $rsi
%0:gr64 = COPY $rdi
%3:gr64 = MOV64rm %0:gr64, 1, $noreg, 0, $noreg :: (load (s64) from %ir.0)
%4:gr64 = AND64ri8 %3:gr64(tied-def 0), 3, implicit-def $eflags
%5:gr64 = CMOV64rr %2:gr64(tied-def 0), %1:gr64, 4, implicit $eflags
MOV64mr %0:gr64, 1, $noreg, 0, $noreg, killed %5:gr64 :: (store (s64) into %ir.0)
$rax = COPY %4:gr64
RET 0, $rax
# End machine code for function _Z3fooPlll.
********** PEEPHOLE OPTIMIZER **********
********** Function: _Z3fooPlll
Encountered load fold barrier on MOV64mr %0:gr64, 1, $noreg, 0, $noreg, killed %5:gr64 :: (store (s64) into %ir.0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment