[llvm] [InstCombine] Teach tryFactorization to treat a disjoint Or like an Add. (PR #75691)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 10 16:03:53 PST 2024
================
@@ -1566,14 +1566,14 @@ define i32 @mul_no_common_bits_uses(i32 %p1, i32 %p2) {
ret i32 %r
}
-; negative test - probably not good to create an extra mul
+; TODO: is it good to create an extra mul?
define i32 @mul_no_common_bits_const_op_uses(i32 %p) {
; CHECK-LABEL: @mul_no_common_bits_const_op_uses(
; CHECK-NEXT: [[X:%.*]] = and i32 [[P:%.*]], 7
; CHECK-NEXT: [[M:%.*]] = mul nuw nsw i32 [[X]], 24
; CHECK-NEXT: call void @use(i32 [[M]])
-; CHECK-NEXT: [[R:%.*]] = or disjoint i32 [[M]], [[X]]
+; CHECK-NEXT: [[R:%.*]] = mul nuw nsw i32 [[X]], 25
----------------
topperc wrote:
I did some investigation of how to add the one use check. It's a little complicated. The optimization can produce a Mul that can be transformed into a Shl. In that case the one use check wouldn't need to apply. The optimization can also turn a Shl into a Mul that would need the one use check to apply.
https://github.com/llvm/llvm-project/pull/75691
More information about the llvm-commits
mailing list