[PATCH] D116058: [InstCombine] Convert binop(phi, v) to phi(binop) for constant phi operands

Guozhi Wei via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 20 15:28:00 PST 2021


Carrot created this revision.
Carrot added a reviewer: craig.topper.
Herald added a subscriber: hiraditya.
Carrot requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

If we have

  %p = phi  [c1, pred1], [c2, pred2]
  %v = add %p, %op 

We'll generate immediate materialization instructions in predecessors. We
 can directly fold them into ALU instructions and create phi instruction for
 the ALU results.

  pred1:
    %op1 = add c1, %op 
    br %bb 
  pred2:
    %op2 = add c2, %op 
    br %bb 
  bb: 
    %v = phi [%op1, pred1], [%op2, pred2]


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116058

Files:
  llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
  llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp
  llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
  llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
  llvm/test/Transforms/InstCombine/narrow.ll
  llvm/test/Transforms/InstCombine/not-add.ll
  llvm/test/Transforms/InstCombine/phi-binary-op.ll
  llvm/test/Transforms/InstCombine/phi.ll
  llvm/test/Transforms/InstCombine/rem.ll
  llvm/test/Transforms/InstCombine/zext-or-icmp.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116058.395528.patch
Type: text/x-patch
Size: 23750 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211220/93e27eb7/attachment.bin>


More information about the llvm-commits mailing list