<div dir="ltr"><div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Dec 18, 2018 at 1:03 PM Tim Northover <<a href="mailto:t.p.northover@gmail.com" target="_blank">t.p.northover@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Tue, 18 Dec 2018 at 07:11, Gleb Popov via llvm-dev<br>
<<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br>
> However, I haven't managed to get a "Constant<>" in the DAG when compiling for X86. I'm interested in how it is lowered. Can you please give me some guidance on this?<br>
<br>
How are you looking? When I run "llc -mtriple=x86_64-linux-gnu<br>
-debug-only=isel" on your IR I get multiple instances of Constants. At<br>
the very start is:<br>
<br>
Initial selection DAG: %bb.0 'main:entry'<br>
SelectionDAG has 18 nodes:<br>
t0: ch = EntryToken<br>
t7: i64 = Constant<0><br>
t9: ch = store<(store 4 into %ir.retval)> t0, Constant:i32<0>,<br>
FrameIndex:i64<0>, undef:i64<br>
t2: i32,ch = CopyFromReg t0, Register:i32 %0<br>
t11: ch = store<(store 4 into %ir.argc.addr)> t9, t2,<br>
FrameIndex:i64<1>, undef:i64<br>
t4: i64,ch = CopyFromReg t0, Register:i64 %1<br>
t13: ch = store<(store 8 into %ir.argv.addr)> t11, t4,<br>
FrameIndex:i64<2>, undef:i64<br>
t16: ch,glue = CopyToReg t13, Register:i32 $eax, Constant:i32<0><br>
t17: ch = X86ISD::RET_FLAG t16, TargetConstant:i32<0>, Register:i32 $eax, t16:1<br>
<br>
where the t16 line corresponds to what you've seen on SPARC.<br>
<br>
Cheers.<br>
<br>
Tim.<br></blockquote><div><br></div><div>Strange. Even using exactly the same command line gives me following output:</div><div><br></div><div># bin/llc -debug-only=isel -mtriple=x86_64-linux-gnu 1.ll<br><br>Changing optimization level for Function main<br> Before: -O2 ; After: -O0<br> FastISel is enabled<br><br><br><br>=== main<br>Enabling fast-isel<br>Total amount of phi nodes to update: 0<br>*** MachineFunction at end of ISel ***<br># Machine code for function main: IsSSA, TracksLiveness<br>Frame Objects:<br> fi#0: size=4, align=4, at location [SP+8]<br> fi#1: size=4, align=4, at location [SP+8]<br> fi#2: size=8, align=8, at location [SP+8]<br>Function Live Ins: %edi in %0, %rsi in %2<br><br>%bb.0: derived from LLVM BB %entry<br> Live Ins: %edi %rsi<br> %2:gr64 = COPY %rsi; GR64:%2<br> %0:gr32 = COPY %edi; GR32:%0<br> %1:gr32 = COPY killed %0; GR32:%1,%0<br> %3:gr64 = COPY killed %2; GR64:%3,%2<br> %4:gr32 = MOV32r0 implicit-def %eflags; GR32:%4<br> MOV32mi %stack.0.retval, 1, %noreg, 0, %noreg, 0; mem:ST4[%retval]<br> MOV32mr %stack.1.argc.addr, 1, %noreg, 0, %noreg, %1; mem:ST4[%argc.addr] GR32:%1<br> MOV64mr %stack.2.argv.addr, 1, %noreg, 0, %noreg, %3; mem:ST8[%argv.addr] GR64:%3<br> %eax = COPY %4; GR32:%4<br> RETQ implicit %eax<br><br># End machine code for function main.<br><br><br>Restoring optimization level for Function main<br> Before: -O0 ; After: -O2<br></div></div></div></div>