[all-commits] [llvm/llvm-project] e6c5d1: [InstCombine] add tests for SimplifySelectsFeeding...

Sanjay Patel via All-commits all-commits at lists.llvm.org
Wed Sep 7 05:23:59 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: e6c5d13ac762e7535191e6c3e16b00fc93433c73
      https://github.com/llvm/llvm-project/commit/e6c5d13ac762e7535191e6c3e16b00fc93433c73
  Author: Sanjay Patel <spatel at rotateright.com>
  Date:   2022-09-07 (Wed, 07 Sep 2022)

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

  Log Message:
  -----------
  [InstCombine] add tests for SimplifySelectsFeedingBinaryOp(); NFC


  Commit: 7c57180900fb6d703c71351e67eaea0f1a25d2e1
      https://github.com/llvm/llvm-project/commit/7c57180900fb6d703c71351e67eaea0f1a25d2e1
  Author: Sanjay Patel <spatel at rotateright.com>
  Date:   2022-09-07 (Wed, 07 Sep 2022)

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

  Log Message:
  -----------
  [InstCombine] fold add+negate through select into sub

This transform came up as a potential DAGCombine in D133282,
so I wanted to see how it escaped in IR too.

We do general folds in InstCombiner::SimplifySelectsFeedingBinaryOp()
by checking if either arm of a select simplifies when the trailing
binop is threaded into the select.

So as long as one side simplifies, it's a good fold to combine a
negate and add into 1 subtract.

This is an example with a zero arm in the select:
https://alive2.llvm.org/ce/z/Hgu_Tj

And this models the tests with a cancelling 'not' op:
https://alive2.llvm.org/ce/z/BuzVV_

Differential Revision: https://reviews.llvm.org/D133369


Compare: https://github.com/llvm/llvm-project/compare/ae05b9dc305f...7c57180900fb


More information about the All-commits mailing list