[PATCH] D150378: [Instsimplfy] X == Y ? 0 : X - Y --> X - Y

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 16 02:55:52 PDT 2023


nikic accepted this revision.
nikic added a comment.
This revision is now accepted and ready to land.

LGTM

I've clarified the preconditions for this function in https://github.com/llvm/llvm-project/commit/8d2bae8c227debdcd0632ce364c58883bd12ad84, so we can actually justify the transform.



================
Comment at: llvm/lib/Analysis/InstructionSimplify.cpp:4250-4252
+      // X == Y ? 0 : X - Y --> X - Y
+      if (Opcode == Instruction::Sub && NewOps[0] == NewOps[1])
+        return Constant::getNullValue(I->getType());
----------------



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150378



More information about the llvm-commits mailing list