[PATCH] D138526: [SimpleLoopUnswitch] unswitch selects

Joshua Cao via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 3 00:56:16 PDT 2023


caojoshua added a comment.

> if possible avoid branching on uninitalized variables, select is fine.

I might be ok with this, would be an easy change. I would not like suggestion 2, because we want passes to work correctly regardless of where its run in the pipeline. I also would avoid suggestion 3, because we want our sanitizers to validate after the transformations.

As nikic pointed out, we are inserting a freeze. Looking at the final IR, the freeze generated by loop unswitch is gone, so I agree that something else is going on. I suspect something is happening further down the optimization pipeline. I'm going to investigate further before I make a decision on where I want to take this patch.

As an exercise, I came up with an example <https://godbolt.org/z/fvP1h164s> with branch unswitching that could cause msan warnings. The freeze instruction there prevents msan warnings. However, if I manually remove the freeze instruction and run it with msan, I do see the use-of-uninitialized-value warning. This showed me its ok to hoist the invariant branch outside of the loop, as long as we insert the freeze instruction.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138526



More information about the llvm-commits mailing list