[PATCH] D75859: [CodeGenPrepare] Fold br(freeze(icmp x, const)) to br(icmp(freeze x, const))

Juneyoung Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 9 17:50:02 PDT 2020


aqjune added a comment.

In D75859#1913094 <https://reviews.llvm.org/D75859#1913094>, @jdoerfert wrote:

> I feel this is part of a bigger pattern. (I assume constants cannot cause poison and undef now)
>
> Let `op` be  `OPERATION<value, constant>` or `OPERATION<constant, value>`, if all uses of `op`, or the single use of `op`, are `freeze`, move `freeze` to `value`.
>
> Now we can keep a list of opcodes for which we don't want to do this but it seems more generic than br + icmp.


This transformation can be generalized as you suggested (maybe instcombine would be the place?), but at this point we don't have a good inference engine for removing freeze from non-i1 values, so I think it may block further optimizations.
Currently `freeze` of i1 type is introduced by SimpleLoopUnswitch (https://reviews.llvm.org/D29015) (it was reverted now, but it is the place where it is likely to introduce freeze in the close future), and `isGuaranteedNotToBeUndefOrPoison` (I'm planning to split it, as you suggested in the other patch) can do inference better on i1 type. So, in terms of performance I'd like to put this transformation at the end of IR pipeline, which is CodeGenPrepare.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75859/new/

https://reviews.llvm.org/D75859





More information about the llvm-commits mailing list