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

Shimin Cui via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 5 10:11:08 PDT 2020


scui 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;
----------------
efriedma wrote:
> 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.
> I guess this handles the case where both operands are bitcasts due to other folds?
Yes, that's right.
> 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.
Yes. I'll leave this for the 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
----------------
efriedma wrote:
> 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.
Thanks for the suggestion. I'll make the variables common.


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

https://reviews.llvm.org/D87850



More information about the llvm-commits mailing list