[all-commits] [llvm/llvm-project] 01ceb9: [InstCombine] Fold (zext (X +nuw C)) + -C --> zext...

Craig Topper via All-commits all-commits at lists.llvm.org
Fri Jul 12 07:40:51 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 01ceb9840a5b768232961444e3606a303ed4beed
      https://github.com/llvm/llvm-project/commit/01ceb9840a5b768232961444e3606a303ed4beed
  Author: Craig Topper <craig.topper at sifive.com>
  Date:   2024-07-12 (Fri, 12 Jul 2024)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
    M llvm/test/Transforms/InstCombine/add.ll

  Log Message:
  -----------
  [InstCombine] Fold (zext (X +nuw C)) + -C --> zext(X) when zext has additional use. (#98533)

We have a general fold for (zext (X +nuw C2)) + C1 --> zext (X + (C2 +
trunc(C1)))
but this fold is disabled if the zext has an additional use.
    
If the two constants cancel, we can fold the whole expression to
zext(X) without increasing the number of instructions.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list