[PATCH] D87850: [ConstantFold] Fold the comparison of bitcasted global values

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 4 22:23:16 PDT 2020


efriedma added inline comments.


================
Comment at: llvm/lib/IR/ConstantFold.cpp:1759
+        if (const GlobalValue *GV2 = dyn_cast<GlobalValue>(V2))
+          return areGlobalsPotentiallyEqual(GV, GV2);
+      LLVM_FALLTHROUGH;
----------------
I guess this handles the case where both operands are bitcasts due to other folds?

Is it possible to end up in a situation where one operand is a bitcast, and the other is a GEP? I guess we could leave that as an area for future improvement.


================
Comment at: llvm/test/Transforms/InstCombine/pr32686.ll:12
-; CHECK-NEXT:    [[TMP1:%.*]] = zext i1 [[TOBOOL]] to i32
-; CHECK-NEXT:    [[OR1:%.*]] = or i32 [[TMP1]], or (i32 zext (i1 icmp ne (i32* bitcast (i8* @a to i32*), i32* @b) to i32), i32 2)
-; CHECK-NEXT:    store i32 [[OR1]], i32* @b, align 4
----------------
I think this test needs a constant expression that won't fold to exercise the right codepath; please adjust the expression so it doesn't fold.

Same applies to the SCCP tests.


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

https://reviews.llvm.org/D87850



More information about the llvm-commits mailing list