[ConstantFold] Fold the comparison of bitcasted global values
authorShimin Cui <scui@ca.ibm.com>
Tue, 20 Oct 2020 19:41:49 +0000 (12:41 -0700)
committerEli Friedman <efriedma@quicinc.com>
Tue, 20 Oct 2020 19:41:49 +0000 (12:41 -0700)
commit95bda510fb7b35ac66fe96b0f24f0ec16005802f
treed1e31d767d4e0b0349607fc068c9ae64291b1abe
parentde6f3d1c71332b2c0ba00a2792c02be72b245d22
[ConstantFold] Fold the comparison of bitcasted global values

This is to simplify icmp instructions in the form like:

%cmp = icmp eq i32 (i8*, i8*)* bitcast (i32 (i32**, i32**)* @f32 to i32
%(i8*, i8*)), bitcast (i32 (i64**, i64**) @f64 to i32 (i8*, i8*)*)

Here @f32 and @f64 are two functions.

Differential Revision: https://reviews.llvm.org/D87850
llvm/lib/IR/ConstantFold.cpp
llvm/test/Transforms/InstCombine/icmp-bitcast-glob.ll [new file with mode: 0644]
llvm/test/Transforms/InstCombine/pr32686.ll
llvm/test/Transforms/SCCP/ip-ranges-select.ll
llvm/test/Transforms/SCCP/undef-resolve.ll