Skip to content

Instantly share code, notes, and snippets.

@minglotus-6
Created April 21, 2022 08:09
Show Gist options
  • Save minglotus-6/fcd07bc00d9bc362b7bd5675ba131740 to your computer and use it in GitHub Desktop.
Save minglotus-6/fcd07bc00d9bc362b7bd5675ba131740 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, t11
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
t6: i64,ch = CopyFromReg t0, Register:i64 %2
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
t14: i64 = select t13, t4, t11
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 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
t11: i64 = and t9, Constant:i64<3>
t13: i1 = setcc t11, Constant:i64<0>, seteq:ch
t4: i64,ch = CopyFromReg t0, Register:i64 %1
t14: i64 = select t13, t4, t11
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 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
t23: i8 = and t20, Constant:i8<1>
t4: i64,ch = CopyFromReg t0, Register:i64 %1
t14: i64 = select t23, t4, t11
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 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
t11: i64 = and t9, Constant:i64<3>
t20: i8 = setcc t11, Constant:i64<0>, seteq:ch
t4: i64,ch = CopyFromReg t0, Register:i64 %1
t14: i64 = select t20, t4, t11
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, t11
Trying custom legalization
Creating new node: t24: i32 = X86ISD::CMP t11, Constant:i64<0>
Creating constant: t25: i8 = TargetConstant<4>
Creating new node: t26: i8 = X86ISD::SETCC TargetConstant:i8<4>, t24
Creating new node: t27: i64 = X86ISD::CMOV t11, t4, TargetConstant:i8<4>, t24
Successfully custom legalized node
... replacing: t14: i64 = select t20, t4, t11
with: t27: i64 = X86ISD::CMOV t11, t4, TargetConstant:i8<4>, t24
Legalizing: t11: i64 = and t9, Constant:i64<3>
Legal node: nothing to do
Legalizing: t9: i64,ch = load<(load (s64) from %ir.0)> t0, t2, undef:i64
Legalizing non-extending load operation
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: t7: i64 = Constant<0>
Legal node: nothing to do
Legalizing: t3: i64 = Register %1
Legalizing: t1: i64 = Register %0
Legalizing: t0: ch = EntryToken
Legal node: nothing to do
Legalizing: t27: i64 = X86ISD::CMOV t11, t4, TargetConstant:i8<4>, t24
Legal node: nothing to do
Legalizing: t25: i8 = TargetConstant<4>
Legalizing: t24: i32 = X86ISD::CMP t11, Constant:i64<0>
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
t11: i64 = and t9, Constant:i64<3>
t4: i64,ch = CopyFromReg t0, Register:i64 %1
t24: i32 = X86ISD::CMP t11, Constant:i64<0>
t27: i64 = X86ISD::CMOV t11, t4, TargetConstant:i8<4>, t24
t15: ch = store<(store (s64) into %ir.0)> t9:1, t27, 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: t27: i64 = X86ISD::CMOV t11, t4, TargetConstant:i8<4>, t24
Legal node: nothing to do
Legalizing: t25: i8 = TargetConstant<4>
Legalizing: t24: i32 = X86ISD::CMP t11, Constant:i64<0>
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, t11
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: t11: i64 = and t9, Constant:i64<3>
Legal node: nothing to do
Legalizing: t9: i64,ch = load<(load (s64) from %ir.0)> t0, t2, undef:i64
Legalizing non-extending load operation
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: t7: i64 = Constant<0>
Legal node: nothing to do
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
t11: i64 = and t9, Constant:i64<3>
t4: i64,ch = CopyFromReg t0, Register:i64 %1
t24: i32 = X86ISD::CMP t11, Constant:i64<0>
t27: i64 = X86ISD::CMOV t11, t4, TargetConstant:i8<4>, t24
t15: ch = store<(store (s64) into %ir.0)> t9:1, t27, 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
===== 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, t11
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 0x7ffc996b51f0
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 t11, t4, TargetConstant:i8<4>, t24
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
Morphed node: t27: i64 = CMOV64rr t11, t4, TargetConstant:i8<4>, t32:1
ISEL: Match complete!
ISEL: Starting selection on root node: t24: i32 = X86ISD::CMP t11, Constant:i64<0>
ISEL: Starting pattern match
Initial Opcode index to 24930
OpcodeSwitch from 24934 to 24939
Match failed at index 24948
Continuing at 25248
Match failed at index 25258
Continuing at 25296
Match failed at index 25301
Continuing at 25339
Match failed at index 25344
Continuing at 25382
Match failed at index 25383
Continuing at 25427
Continuing at 25428
Continuing at 25834
Skipped scope entry (due to false predicate) at index 25839, continuing at 25870
Skipped scope entry (due to false predicate) at index 25871, continuing at 25902
Skipped scope entry (due to false predicate) at index 25903, continuing at 25934
Match failed at index 25938
Continuing at 25966
Continuing at 25967
OpcodeSwitch from 25970 to 26074
Match failed at index 26090
Continuing at 26139
Match failed at index 26145
Continuing at 26162
Continuing at 26163
Match failed at index 26167
Continuing at 26185
Match failed at index 26189
Continuing at 26207
Match failed at index 26211
Continuing at 26229
Match failed at index 26230
Continuing at 26253
Continuing at 26254
Match failed at index 26262
Continuing at 26280
Match failed at index 26285
Continuing at 26303
Match failed at index 26308
Continuing at 26326
Match failed at index 26327
Continuing at 26351
Continuing at 26352
Continuing at 26354
Skipped scope entry (due to false predicate) at index 26359, continuing at 26423
Skipped scope entry (due to false predicate) at index 26424, continuing at 26524
Skipped scope entry (due to false predicate) at index 26525, continuing at 26625
Morphed node: t24: i32 = TEST64rr t11, t11
ISEL: Match complete!
ISEL: Starting selection on root node: t11: i64 = and t9, Constant:i64<3>
ISEL: Starting pattern match
Initial Opcode index to 44832
OpcodeSwitch from 44836 to 44841
Match failed at index 44843
Continuing at 45124
Match failed at index 45127
Continuing at 45230
OpcodeSwitch from 45233 to 45237
Match failed at index 45239
Continuing at 45501
Match failed at index 45504
Continuing at 45625
Match failed at index 45627
Continuing at 45751
Match failed at index 45752
Continuing at 45824
Match failed at index 45825
Continuing at 45860
Match failed at index 45863
Continuing at 45966
Match failed at index 45968
Continuing at 46075
Match failed at index 46078
Continuing at 46176
Match failed at index 46178
Continuing at 46277
Match failed at index 46278
Continuing at 46303
Match failed at index 46304
Continuing at 46361
Match failed at index 46362
Continuing at 46404
Match failed at index 46405
Continuing at 46445
Match failed at index 46446
Continuing at 46485
Skipped scope entry (due to false predicate) at index 46495, continuing at 46516
Creating constant: t33: i64 = TargetConstant<0>
Creating constant: t34: i32 = TargetConstant<6>
Creating new machine node: t35: i32 = EXTRACT_SUBREG t9, TargetConstant:i32<6>
Created node: t35: i32 = EXTRACT_SUBREG t9, TargetConstant:i32<6>
Creating constant: t36: i64 = TargetConstant<3>
Creating constant: t37: i32 = TargetConstant<3>
Creating new machine node: t38: i32,i32 = AND32ri8 t35, TargetConstant:i32<3>
Created node: t38: i32,i32 = AND32ri8 t35, TargetConstant:i32<3>
Morphed node: t11: i64 = SUBREG_TO_REG TargetConstant:i64<0>, t38, TargetConstant:i32<6>
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 0x7ffc996b51f0
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: 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: 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 26 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
t35: i32 = EXTRACT_SUBREG t9, TargetConstant:i32<6>
t38: i32,i32 = AND32ri8 t35, TargetConstant:i32<3>
t11: i64 = SUBREG_TO_REG TargetConstant:i64<0>, t38, TargetConstant:i32<6>
t4: i64,ch = CopyFromReg t0, Register:i64 %1
t24: i32 = TEST64rr t11, t11
t32: ch,glue = CopyToReg t0, Register:i32 $eflags, t24
t27: i64 = CMOV64rr t11, 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, t11
t36: i64 = TargetConstant<3>
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
bb.0 (%ir-block.3):
liveins: $rdi, $rsi
%1:gr64 = COPY $rsi
%0:gr64 = COPY $rdi
%3:gr64 = MOV64rm %0:gr64, 1, $noreg, 0, $noreg :: (load (s64) from %ir.0)
%4:gr32 = COPY %3.sub_32bit:gr64
%5:gr32 = AND32ri8 %4:gr32(tied-def 0), 3, implicit-def dead $eflags
%6:gr64 = SUBREG_TO_REG 0, killed %5:gr32, %subreg.sub_32bit
TEST64rr %6:gr64, %6:gr64, implicit-def $eflags
%7:gr64 = CMOV64rr %6:gr64(tied-def 0), %1:gr64, 4, implicit $eflags
MOV64mr %0:gr64, 1, $noreg, 0, $noreg, killed %7:gr64 :: (store (s64) into %ir.0)
$rax = COPY %6:gr64
RET 0, $rax
# End machine code for function _Z3fooPlll.
********** PEEPHOLE OPTIMIZER **********
********** Function: _Z3fooPlll
Attempting to optimize compare: TEST64rr %6:gr64, %6:gr64, implicit-def $eflags
Encountered load fold barrier on MOV64mr %0:gr64, 1, $noreg, 0, $noreg, killed %7:gr64 :: (store (s64) into %ir.0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment