[PATCH] D127960: [InstCombine] Push freeze through recurrence phi

Nuno Lopes via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 16 06:44:53 PDT 2022


nlopes added inline comments.


================
Comment at: llvm/test/Transforms/InstCombine/freeze.ll:746
 ; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[INIT_FR:%.*]] = freeze i32 [[INIT:%.*]]
 ; CHECK-NEXT:    br label [[LOOP:%.*]]
----------------
This case is annoying because if undef didn't exist*, we could get rid of the freeze here altogether.
The reason is that if %init=poison, then %init.fr becomes any value we want. 
Since the add below is nuw, we can pick a convenient value that makes the addition overflow and thus poison.
Thus, if %init is poison, %cond becomes poison, and the loop triggers UB.

* The argument still applies to full undef values. But it does not for values that are partially undef (e.g., (undef & 1) | (x & ~1)). We've never enabled partial undefs in Alive2 because they are quite expensive and we only had some artificial examples on when they are needed. But this example shows it well.
We can decide to ignore partial undefs here, or at least leave a FIXME for that day when we remove undef from LLVM 🤣


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

https://reviews.llvm.org/D127960



More information about the llvm-commits mailing list