[PATCH] D150142: [InstCombine] Add simplifications for div/rem with `i1` operands; PR62607
Zhu Siyuan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 9 08:34:35 PDT 2023
floatshadow added a comment.
In D150142#4327941 <https://reviews.llvm.org/D150142#4327941>, @goldstein.w.n wrote:
> Edit:
> Hers a minimal reproduction:
>
> define i1 @foo(i1 %c, i1 %x, i1 %y) {
> br i1 %c, label %true, label %false
> true:
> %y_true = and i1 %y, 0
> br label %done
> false:
> %y_false = and i1 %y, 0
> br label %done
> done:
> %yy = phi i1 [ %y_false, %false ], [ %y_true, %true ]
> %r = sdiv i1 %x, %yy
> ret i1 %r
> }
>
> There needs to be some non-trivial zero pattern so it doesn't get constant folded.
> Either returning `poison` or `op0` is fine:
> https://alive2.llvm.org/ce/z/9RuT_m
> poison probably makes more sense though.
I guess this reproduction need some refinement. `KnownBits` actually neglects zero cases, but the `threadBinOpOverPHI` would do recursive check which later got folded in a pattern match `if (match(Op1, m_Zero()))` in `simplifyDivRem`
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D150142/new/
https://reviews.llvm.org/D150142
More information about the llvm-commits
mailing list