History log of /llvm-project/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp (Results 51 – 75 of 463)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# dfe1d35c 19-Nov-2023 Yingwei Zheng <dtcxzyw2333@gmail.com>

[InstCombine] Propagate NSW/NUW flags for `(X - Y) - Z -> X - (Y + Z)` (#72693)

Alive2: https://alive2.llvm.org/ce/z/gqeaVo

Related patch:
https://github.com/llvm/llvm-project/commit/31d219d2997

[InstCombine] Propagate NSW/NUW flags for `(X - Y) - Z -> X - (Y + Z)` (#72693)

Alive2: https://alive2.llvm.org/ce/z/gqeaVo

Related patch:
https://github.com/llvm/llvm-project/commit/31d219d2997fed1b7dc97e0adf170d5aaf65883e

show more ...


# 8e516d48 15-Nov-2023 Yingwei Zheng <dtcxzyw2333@gmail.com>

[InstCombine] Infer nuw flags for `C-(X+C2)` -> `(C-C2)-X` (#72373)

This patch improves https://reviews.llvm.org/D152068 by inferring NUW
flags for sub insts.
It is worth noting that we don't need

[InstCombine] Infer nuw flags for `C-(X+C2)` -> `(C-C2)-X` (#72373)

This patch improves https://reviews.llvm.org/D152068 by inferring NUW
flags for sub insts.
It is worth noting that we don't need to check overflow for `C-C2`.
Alive2: https://alive2.llvm.org/ce/z/uutGpS

This missed optimization is discovered with the help of
https://github.com/AliveToolkit/alive2/pull/962.

show more ...


# 76ba6606 14-Nov-2023 Z572 <zhengjunjie@iscas.ac.cn>

[InstCombine] Follow-up to "When -A + B both have nsw flag, set nsw f… (#72282)

…lag."

In 3c037b7306f57039e24a1470687cc39a795584ac, Use cast instead of dyn_cast for cast that cannot fail.


# 3c037b73 14-Nov-2023 Z572 <zhengjunjie@iscas.ac.cn>

[InstCombine] When -A + B both have nsw flag, set nsw flag. (#72127)

Fixes #72119

https://alive2.llvm.org/ce/z/5f_QuC


# 25af06fd 06-Nov-2023 Nikita Popov <npopov@redhat.com>

[InstCombine] Avoid use of FP cast constant expressions (NFC)

Use the constant folding API instead. As we're working on plain
ConstantFP, this should always succeed.


# be57381a 17-Oct-2023 Dhruv Chawla <dhruv263.dc@gmail.com>

[InstCombine] Create a class to lazily track computed known bits (#66611)

This patch adds a new class "WithCache" which stores a pointer to
any type passable to computeKnownBits along with KnownBit

[InstCombine] Create a class to lazily track computed known bits (#66611)

This patch adds a new class "WithCache" which stores a pointer to
any type passable to computeKnownBits along with KnownBits
information which is computed on-demand when getKnownBits()
is called. This allows reusing the known bits information when it is
passed as an argument to multiple functions.

It also changes a few functions to accept WithCache(s) so that
known bits information computed in some callees can be propagated to
others from the top level visitAddSub caller.

This gives a speedup of 0.14%:
https://llvm-compile-time-tracker.com/compare.php?from=499d41cef2e7bbb65804f6a815b9fa8b27efce0f&to=fbea87f1f1e6d5552e2bc309f8e201a3af6d28ec&stat=instructions:u

show more ...


# 80fa5a63 10-Oct-2023 Nikita Popov <npopov@redhat.com>

[ValueTracking] Use SimplifyQuery in haveNoCommonBitsSet() (NFC)

Pass SimplifyQuery instead of unpacked list of arguments.


# 1b8fb1a6 28-Sep-2023 Nikita Popov <npopov@redhat.com>

[InstCombine] Avoid some uses of ConstantExpr::getZExt() (NFC)

Let the IRBuilder constant fold instead.


Revision tags: llvmorg-17.0.0-rc4, llvmorg-17.0.0-rc3
# 1fc73cac 21-Aug-2023 Nikita Popov <npopov@redhat.com>

[InstCombine] Propagate nsw flag when negating

When pushing a sub nsw 0, %x negation into an expression, try to
preserve the nsw flag for the cases where this is possible. Do this
by passing the fla

[InstCombine] Propagate nsw flag when negating

When pushing a sub nsw 0, %x negation into an expression, try to
preserve the nsw flag for the cases where this is possible. Do this
by passing the flag through recursive Negator::negate() calls.

Proofs: https://alive2.llvm.org/ce/z/oRPNcY

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

show more ...


# 3af45905 01-Sep-2023 Christoph Stiller <c.stiller@live.de>

[InstCombine] Contracting x^2 + 2*x*y + y^2 to (x + y)^2 (float)

Resolves https://github.com/llvm/llvm-project/issues/61296 if https://reviews.llvm.org/D156026 didn't suffice.

Reviewed By: goldstei

[InstCombine] Contracting x^2 + 2*x*y + y^2 to (x + y)^2 (float)

Resolves https://github.com/llvm/llvm-project/issues/61296 if https://reviews.llvm.org/D156026 didn't suffice.

Reviewed By: goldstein.w.n

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

show more ...


Revision tags: llvmorg-17.0.0-rc2
# 033d6ffb 03-Aug-2023 Matt Arsenault <Matthew.Arsenault@amd.com>

IR: Add operator | and & for FastMathFlags

We only had |= and &= which was annoying.


# 9c375a45 17-Aug-2023 Noah Goldstein <goldstein.w.n@gmail.com>

[InstCombine] Transform `(add (shl (neg X), Cnt))` -> `(sub (shl X, Cnt))`

Just a simple instruction save.

Proof: https://alive2.llvm.org/ce/z/Vb484j

Reviewed By: nikic

Differential Revision: htt

[InstCombine] Transform `(add (shl (neg X), Cnt))` -> `(sub (shl X, Cnt))`

Just a simple instruction save.

Proof: https://alive2.llvm.org/ce/z/Vb484j

Reviewed By: nikic

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

show more ...


# f7f5d348 02-Aug-2023 Matt Arsenault <Matthew.Arsenault@amd.com>

InstCombine: Fold fneg (ldexp x, n) -> ldexp (fneg x), n

https://reviews.llvm.org/D156579


# 0bdab96a 09-Aug-2023 Christoph Stiller <c.stiller@live.de>

[InstCombine] Contract x^2 + 2*x*y + y^2 to (x + y)^2 (integer)

There are a number of variations on the pattern, depending on
order.

Proof: https://alive2.llvm.org/ce/z/ri5iFw

Differential Revisio

[InstCombine] Contract x^2 + 2*x*y + y^2 to (x + y)^2 (integer)

There are a number of variations on the pattern, depending on
order.

Proof: https://alive2.llvm.org/ce/z/ri5iFw

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

show more ...


# 020d2fb7 02-Aug-2023 Matt Arsenault <Matthew.Arsenault@amd.com>

InstCombine: Avoid repeated m_OneUse checks

The check was repeated for the fmul and fdiv case, and the caller was
already checking anyway.


# ed0dbfef 02-Aug-2023 Matt Arsenault <Matthew.Arsenault@amd.com>

InstCombine: Remove dead fsub-as-fneg handling

The above combine matching m_FNeg to produce a new fneg always would
hide this.


Revision tags: llvmorg-17.0.0-rc1, llvmorg-18-init
# f12a5561 05-Jul-2023 Antonio Frighetto <me@antoniofrighetto.com>

[InstCombine] Fold binop of `select` and cast of `select` condition

Simplify binary operations, whose operands involve a `select`
instruction and a cast of the `select` condition. Specifically,
the

[InstCombine] Fold binop of `select` and cast of `select` condition

Simplify binary operations, whose operands involve a `select`
instruction and a cast of the `select` condition. Specifically,
the binop is canonicalized into a `select` with folded arguments
as follows:

(Binop (zext C), (select C, T, F))
-> (select C, (binop 1, T), (binop 0, F))

(Binop (sext C), (select C, T, F))
-> (select C, (binop -1, T), (binop 0, F))

Proofs: https://alive2.llvm.org/ce/z/c_JwwM

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

show more ...


# 21827268 14-Jul-2023 Nikita Popov <npopov@redhat.com>

[InstCombine] Fold add of zext and sext of i1

(zext a) + (sext a) is 0 if a is a bool.

The regression is in a fuzzer-generated test.

Proof: https://alive2.llvm.org/ce/z/KotnN6


Revision tags: llvmorg-16.0.6, llvmorg-16.0.5, llvmorg-16.0.4, llvmorg-16.0.3, llvmorg-16.0.2
# 0f4eb557 13-Apr-2023 Matt Arsenault <Matthew.Arsenault@amd.com>

ValueTracking: Replace CannotBeNegativeZero

This is now just a wrapper around computeKnownFPClass.


# b45a73f4 14-Jun-2023 Nikita Popov <npopov@redhat.com>

[InstCombine] Fold binop of shifts with related amounts

Fold

binop(shift(ShiftedC1, ShAmt), shift(ShiftedC2, add(ShAmt, AddC)))
->
shift(binop(ShiftedC1, shift(ShiftedC2, AddC)), ShAmt)

wh

[InstCombine] Fold binop of shifts with related amounts

Fold

binop(shift(ShiftedC1, ShAmt), shift(ShiftedC2, add(ShAmt, AddC)))
->
shift(binop(ShiftedC1, shift(ShiftedC2, AddC)), ShAmt)

where both shifts are the same and AddC is a valid shift amount.

Proofs: https://alive2.llvm.org/ce/z/PhVVeg

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

show more ...


# 91cdffcb 14-Jun-2023 Noah Goldstein <goldstein.w.n@gmail.com>

[InstCombine] Transform `(binop1 (binop2 (lshift X,Amt),Mask),(lshift Y,Amt))`

If `Mask` and `Amt` are not constants and `binop1` and `binop2` are
the same we can transform to:
`(binop (lshift (bino

[InstCombine] Transform `(binop1 (binop2 (lshift X,Amt),Mask),(lshift Y,Amt))`

If `Mask` and `Amt` are not constants and `binop1` and `binop2` are
the same we can transform to:
`(binop (lshift (binop X, Y), Amt), Mask)`

If `binop` is `add`, `lshift` must be `shl`.

If `Mask` and `Amt` are constants `C` and `C1` respectively.
We can transform to:
`(lshift1 (binop1 (binop2 X, (inv_lshift1 C, C1), Y)), C1)`

Saving an instruction IFF:
`lshift1` is same opcode as `lshift2`
Either `bitwise1` and/or `bitwise2` is `and`.

Proofs(1/2): https://alive2.llvm.org/ce/z/BjN-m_
Proofs(2/2): https://alive2.llvm.org/ce/z/bZn5QB

This is to help fix the regression caused in D151807

Reviewed By: nikic

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

show more ...


# 116670d1 04-Jun-2023 khei4 <kk.asano.luxy@gmail.com>

[InstCombine] add overflow checking on Add ~X + C --> (C-1) - X
Differential Revision: https://reviews.llvm.org/D152088


# 4db8d4f8 04-Jun-2023 khei4 <kk.asano.luxy@gmail.com>

[InstCombine] add overflow checking on AddSub `C-(X+C2) --> (C-C2)-X`
Differential Revision: https://reviews.llvm.org/D152068


Revision tags: llvmorg-16.0.1
# f38365ae 31-Mar-2023 Serguei Katkov <serguei.katkov@azul.com>

[InstCombine] Add support for maximum(a,b) + minimum(a,b) => a + b

Unfortunately alive2 cannot prove the correctness due to fails by timeout even for
float type half.

However it should be correct.

[InstCombine] Add support for maximum(a,b) + minimum(a,b) => a + b

Unfortunately alive2 cannot prove the correctness due to fails by timeout even for
float type half.

However it should be correct. If a and b are not NaN, maximum and minimum will just
return different values (a and b) and take into account a + b == b + a this is the same.
If a or b is NaN, than maximum and minimum are equal to NaN and NaN + NaN is NaN.
a + b is also a NaN.

In terms of preserving fast flags, we cannot preserve ninf due to
minimum(NaN, Infinity) == maximum(NaN, Infinity) == NaN,
minimum(NaN, Infinity) +ninf maximum(NaN, Infinity) == NaN +ninf NaN = NaN
However transformation will change
minimum(NaN, Infinity) + maximum(NaN, Infinity) to NaN +ninf Infinity == poison.

But if fadd is marked as nnan, we can preserve because NaN +ninf/nnan NaN = poison as well.

The same optimization for
maximum(a,b) * minimum(a,b) => a * b
is added.
All said above for fadd is correct for fmul.

Reviewed By: mkazantsev
Differential Revision: https://reviews.llvm.org/D147299

show more ...


# 62497380 07-Apr-2023 Serguei Katkov <serguei.katkov@azul.com>

[InstCombine] Add support for max(a,b) + min(a,b) => a + b. Re-land.

The same optimization for
max(a,b) * min(a,b) => a * b
is added.

Correctness check:
uadd: https://alive2.llvm.org/ce/z/2rXDek

[InstCombine] Add support for max(a,b) + min(a,b) => a + b. Re-land.

The same optimization for
max(a,b) * min(a,b) => a * b
is added.

Correctness check:
uadd: https://alive2.llvm.org/ce/z/2rXDek
sadd: https://alive2.llvm.org/ce/z/zNu_er
uadd + nuw/nsw: https://alive2.llvm.org/ce/z/EaiNjB
sadd + nuw/nsw: https://alive2.llvm.org/ce/z/w_2Nrs

umul: https://alive2.llvm.org/ce/z/dgXRLr
smul: https://alive2.llvm.org/ce/z/hBjGzz
umul + nuw/nsw: https://alive2.llvm.org/ce/z/EaiNjB
smul + nuw/nsw: https://alive2.llvm.org/ce/z/87MNeS

Reviewed By: goldstein.w.n
Differential Revision: https://reviews.llvm.org/D147296

show more ...


12345678910>>...19