[PATCH] D90113: [DAGCombiner] Fold BinOp into Select containing identity constant
    Layton Kifer via Phabricator via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Sat Oct 24 23:21:56 PDT 2020
    
    
  
laytonio created this revision.
laytonio added reviewers: craig.topper, lebedev.ri, spatel, RKSimon.
Herald added subscribers: llvm-commits, ecnelises, kerbowa, pengfei, asbirlea, atanasyan, jrtc27, kbarton, hiraditya, nhaehnle, jvesely, nemanjai, sdardis.
Herald added a project: LLVM.
laytonio requested review of this revision.
To prevent materializing unneeded identity constants, and to avoid unnecessary arithmetic in branches that where the value wouldn't be modified, add folds for the following:
(add x, (select cc, 0, cf)) -> (select cc, x, (add x, cf))
(or x, (select cc, 0, cf)) -> (select cc, x, (or x, cf))
(xor x, (select cc, 0, cf)) -> (select cc, x, (xor x, cf))
(sub x, (select cc, 0, cf)) -> (select cc, x, (sub x, cf))
(shl x, (select cc, 0, cf)) -> (select cc, x, (shl x, cf))
(lshr x, (select cc, 0, cf)) -> (select cc, x, (lshr x, cf))
(ashr x, (select cc, 0, cf)) -> (select cc, x, (ashr x, cf))
(mul x, (select cc, 1, cf)) -> (select cc, x, (mul x, cf))
(sdiv x, (select cc, 1, cf)) -> (select cc, x, (sdiv x, cf))
(udiv x, (select cc, 1, cf)) -> (select cc, x, (udiv x, cf))
(and x, (select cc, -1, cf)) -> (select cc, x, (and x, cf))
Fixes select cases of PR47922
Repository:
  rG LLVM Github Monorepo
https://reviews.llvm.org/D90113
Files:
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/test/CodeGen/AArch64/half.ll
  llvm/test/CodeGen/AArch64/midpoint-int.ll
  llvm/test/CodeGen/AArch64/use-cr-result-of-dom-icmp-st.ll
  llvm/test/CodeGen/AMDGPU/amdgpu-codegenprepare-idiv.ll
  llvm/test/CodeGen/AMDGPU/bypass-div.ll
  llvm/test/CodeGen/AMDGPU/idiv-licm.ll
  llvm/test/CodeGen/AMDGPU/sdiv.ll
  llvm/test/CodeGen/AMDGPU/sdiv64.ll
  llvm/test/CodeGen/AMDGPU/srem64.ll
  llvm/test/CodeGen/AMDGPU/udiv64.ll
  llvm/test/CodeGen/AMDGPU/urem64.ll
  llvm/test/CodeGen/Mips/funnel-shift-rot.ll
  llvm/test/CodeGen/Mips/funnel-shift.ll
  llvm/test/CodeGen/Mips/llvm-ir/ashr.ll
  llvm/test/CodeGen/Mips/llvm-ir/lshr.ll
  llvm/test/CodeGen/Mips/llvm-ir/shl.ll
  llvm/test/CodeGen/PowerPC/cmpb-ppc32.ll
  llvm/test/CodeGen/PowerPC/cmpb.ll
  llvm/test/CodeGen/PowerPC/combine_ext_trunc.ll
  llvm/test/CodeGen/PowerPC/fp-strict-conv-f128.ll
  llvm/test/CodeGen/PowerPC/noPermuteFormasking.ll
  llvm/test/CodeGen/PowerPC/nofpexcept.ll
  llvm/test/CodeGen/PowerPC/ppcf128-constrained-fp-intrinsics.ll
  llvm/test/CodeGen/PowerPC/rlwimi-and.ll
  llvm/test/CodeGen/PowerPC/use-cr-result-of-dom-icmp-st.ll
  llvm/test/CodeGen/SystemZ/subregliveness-04.ll
  llvm/test/CodeGen/Thumb2/LowOverheadLoops/predicated-liveout-unknown-lanes.ll
  llvm/test/CodeGen/X86/avx-select.ll
  llvm/test/CodeGen/X86/avx512-select.ll
  llvm/test/CodeGen/X86/binop-identity.ll
  llvm/test/CodeGen/X86/bool-simplify.ll
  llvm/test/CodeGen/X86/bool-vector.ll
  llvm/test/CodeGen/X86/fp-cvt.ll
  llvm/test/CodeGen/X86/fp-intrinsics-flags.ll
  llvm/test/CodeGen/X86/fp-intrinsics.ll
  llvm/test/CodeGen/X86/fp-strict-scalar-fptoint.ll
  llvm/test/CodeGen/X86/fp80-strict-scalar.ll
  llvm/test/CodeGen/X86/jump_sign.ll
  llvm/test/CodeGen/X86/midpoint-int.ll
  llvm/test/CodeGen/X86/pr22338.ll
  llvm/test/CodeGen/X86/pr33954.ll
  llvm/test/CodeGen/X86/pr47482.ll
  llvm/test/CodeGen/X86/scalar-fp-to-i64.ll
  llvm/test/CodeGen/X86/setcc-combine.ll
  llvm/test/CodeGen/X86/use-cr-result-of-dom-icmp-st.ll
  llvm/test/CodeGen/X86/vec-strict-fptoint-128.ll
  llvm/test/CodeGen/X86/vec-strict-fptoint-256.ll
  llvm/test/CodeGen/X86/vec-strict-fptoint-512.ll
  llvm/test/CodeGen/X86/zext-sext.ll
  llvm/test/tools/llvm-locstats/locstats.ll
    
    
More information about the llvm-commits
mailing list