[PATCH] D110339: SelectionDAGBuilder: Improve canonicalization by not swapping branch targets

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 23 09:44:15 PDT 2021


RKSimon added inline comments.


================
Comment at: llvm/test/CodeGen/X86/2006-08-21-ExtraMovInst.ll:15
+; CHECK-NEXT:    cmpl $39, %ecx
+; CHECK-NEXT:    jle .LBB0_1
 ; CHECK-NEXT:  # %bb.2: # %bb12
----------------
craig.topper wrote:
> MatzeB wrote:
> > RKSimon wrote:
> > > This kind of thing is going to increase EFLAGS usage - I addressed this for CMOVs + SETs with SGT/UGT in D101074 but haven't had time to address JMP/BRANCH, or add the SLE/ULE equivalent yet.
> > > This kind of thing is going to increase EFLAGS usage
> > 
> > Wow, I was not aware that affects performance. Does that mean MachineCodePlacement / analyzeBranch can pessimize code when it flips the true/false branches and negates the condition of a jump?
> At least on Intel CPUs, I'm not aware of a performance issue for jumps. There is an extra uop for CMOV and SETCC conditions that use the C flag and Z flag. That would cmovbe, cmova, setbe, and seta. There is no extra uop for branches on the same conditions.
> 
> I can't speak to AMD CPUs.
Its often tricky to see the effect of this in real world code, but yes we should always be trying to minimize the number of EFLAGS bits we depend on. Some x86 cpus split the dependencies into individual/groups of bits, others keep them together, its quite a mess and isn't something we've properly tried to model......

I'll see if I can resurrect the followups to D101074 - iirc I encountered a similar mammoth test churn to you in this patch.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110339/new/

https://reviews.llvm.org/D110339



More information about the llvm-commits mailing list