[PATCH] D159464: [InstCombine] Fold comparison of adding two zero extended booleans

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 7 16:53:45 PDT 2023


goldstein.w.n added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp:2912
+      Op1->getType()->isIntOrIntVectorTy(1) &&
+      (C.isZero() || C.isOne() || (C.exactLogBase2() == 1))) {
+    Value *Cond = Builder.getFalse();
----------------
You can do here or add TODO for exanding to arbtirary `C`
For the most part all values but a handful are just constant simplifications.
For `sext` `-1` and `-2` are basically parallels to the `zext` only case.


================
Comment at: llvm/test/Transforms/InstCombine/icmp-add.ll:133
+  ret i1 %t
+}
+
----------------
Missing test for `icmp ne` (which I think you will incorrectly simplify as `false` when it should be `true`).


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

https://reviews.llvm.org/D159464



More information about the llvm-commits mailing list