[PATCH] D103861: [Attributor] Look through selects in genericValueTraversal

Stefanos Baziotis via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 10 16:34:43 PDT 2021


baziotis added a comment.

LGTM although I've missed a lot of progress in the Attributor so definitely wait for other reviewers if you want an acceptance to move it forward :)



================
Comment at: llvm/lib/Transforms/IPO/AttributorAttributes.cpp:310
+        continue;
+      if (auto *CI = dyn_cast_or_null<ConstantInt>(*C)) {
+        if (CI->isZero())
----------------
jdoerfert wrote:
> baziotis wrote:
> > Not important but `SI->getCondition()` should return either an `i1` or a vector of `i1`. I don't know what's happening in `getAssumedConstant()` but I assume it doesn't deal with vectors which means that if `C.hasValue()` and it is //not// `undef`, then it //must// be a `ConstantInt`? So, maybe put that in an `assert()`. OTOH, if later you decide to deal with vectors, those asserts will fire while in this you can just add an `else if`. Anyway, just wanted to bring it to the foreground and you can choose what is better.
> It must not be a constantint, even if there are no vectors. 
> 
> ```
> int foo(bool A) {
>   B = !A;
>   C = !B;
>   return C ? 0: 42;
> }
> ```
> `C` here is a i1, simplified value is (potentially) `A` which is neither constant nor vector.
Ok, something I probably missed here, which I should've have inferred from the usage of `isa_and_nonnull` and `dyn_cast_or_null`, is that `C` may have a value (i.e., `C.hasValue() == true`) but its value may be `null`. Hm.., then why the `Optional`? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103861



More information about the llvm-commits mailing list