[all-commits] [llvm/llvm-project] 36cfea: [X86] Add tests for inverting `(x * (Pow2_Ceil(C1)...
goldsteinn via All-commits
all-commits at lists.llvm.org
Sat May 13 12:36:38 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 36cfea5a98fd09e61f91937547c7796318f2c026
https://github.com/llvm/llvm-project/commit/36cfea5a98fd09e61f91937547c7796318f2c026
Author: Noah Goldstein <goldstein.w.n at gmail.com>
Date: 2023-05-13 (Sat, 13 May 2023)
Changed paths:
A llvm/test/CodeGen/X86/undo-mul-and.ll
Log Message:
-----------
[X86] Add tests for inverting `(x * (Pow2_Ceil(C1) - (1 << C0))) & C1` -> `(-x << C0) & C1`; NFC
Differential Revision: https://reviews.llvm.org/D150293
Commit: 6c3bf364bf95209925b1e884077ec79cca274dc7
https://github.com/llvm/llvm-project/commit/6c3bf364bf95209925b1e884077ec79cca274dc7
Author: Noah Goldstein <goldstein.w.n at gmail.com>
Date: 2023-05-13 (Sat, 13 May 2023)
Changed paths:
M llvm/lib/Target/X86/X86ISelLowering.cpp
M llvm/test/CodeGen/X86/undo-mul-and.ll
Log Message:
-----------
[X86] Invert transforming `(x * (Pow2_Ceil(C1) - (1 << C0))) & C1` -> `(-x << C0) & C1`
We can detect the case under the following circumstances:
Take `(Pow2_Ceil(C1) - (1 << C0))` as `C2`.
1) `C2` is NOT a power of 2.
2) `C2 + LeastSignificantBit(C2)` is a nonzero power of 2.
3) `C2 u>= C1`
The motivation is the middle end transforms:
`(-x << C0) & C1`
to
`(x * (Pow2_Ceil(C1) - (1 << C2))) & C1`
As it saves IR instructions. On X86 the two instruction, `sub` and
`shl`, and better than the `mul` so we want to undo the transform.
This comes up when shifting a bit-mask by a byte-misalignment i.e:
`y << ((-(uintptr)x * 8) & 63)`
Alive2 Proofs (including all cases with undefs in the vector):
https://alive2.llvm.org/ce/z/f-65b6
Reviewed By: RKSimon, pengfei
Differential Revision: https://reviews.llvm.org/D150294
Commit: ab1b42ac5cb82cd7d541caa06e7929825b4fed84
https://github.com/llvm/llvm-project/commit/ab1b42ac5cb82cd7d541caa06e7929825b4fed84
Author: Noah Goldstein <goldstein.w.n at gmail.com>
Date: 2023-05-13 (Sat, 13 May 2023)
Changed paths:
M llvm/lib/Analysis/InstructionSimplify.cpp
A llvm/test/Transforms/InstCombine/div-i1.ll
Log Message:
-----------
[InstCombine] Add simplifications for div/rem with `i1` operands; PR62607
This is generally handled already in early CSE.
If a specialized pipeline is used, however, its possible for `i1`
operand with known-zero denominator to slip through. Generally the
known-zero denominator is caught and poison is returned, but if it is
indirect enough (known zero through a phi node) we can miss this case
in `InstructionSimplify` and then miss handling `i1`. This is because
`i1` is current handled with the following check:
`if(Known.countMinLeadingZeros() == Known.getBitWidth() - 1)`
which only works on the assumption we don't know the denominator to be
zero. If we know the denominator to be zero, this check fails:
https://github.com/llvm/llvm-project/issues/62607
This patch simply adds an explicit `if(Known.isZero) return poison;`
which fixes the issue.
Alive2 Link for tests:
https://alive2.llvm.org/ce/z/VTw54n
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D150142
Commit: da9f306739a60508f9ab10f2cea939b7a6e2d328
https://github.com/llvm/llvm-project/commit/da9f306739a60508f9ab10f2cea939b7a6e2d328
Author: Noah Goldstein <goldstein.w.n at gmail.com>
Date: 2023-05-13 (Sat, 13 May 2023)
Changed paths:
M llvm/include/llvm/CodeGen/SelectionDAG.h
M llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
Log Message:
-----------
[SelectionDAG] Limit max recursion in `isKnownNeverZero` and `isKnownToBeAPowerOfTwo`
Both of these functions recursively call themselves so it makes sense
to limit that upper bound.
Differential Revision: https://reviews.llvm.org/D149195
Commit: e36caaeeb25fafba0851e4a1905c7ceb08c337a8
https://github.com/llvm/llvm-project/commit/e36caaeeb25fafba0851e4a1905c7ceb08c337a8
Author: Noah Goldstein <goldstein.w.n at gmail.com>
Date: 2023-05-13 (Sat, 13 May 2023)
Changed paths:
M llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
M llvm/test/CodeGen/ARM/cttz_vector.ll
Log Message:
-----------
[SelectionDAG] Use `computeKnownBits` if `Op` is not recognized by `isKnownNeverZero`
The current logic is pretty limitted unless the `Op` is a
constant. This at least covers more obvious cases.
Reviewed By: craig.topper, foad
Differential Revision: https://reviews.llvm.org/D149196
Compare: https://github.com/llvm/llvm-project/compare/94f7c961c78d...e36caaeeb25f
More information about the All-commits
mailing list