We can simplify
icmp <pred> phi(C1, C2, ...), C
with
phi(icmp(C1, C), icmp(C2, C), ...)
provided that all comparison of constants are constants themselves.
Differential D81151
[InstCombine] Simplify compare of Phi with constant inputs against a constant mkazantsev on Jun 4 2020, 5:31 AM. Authored by
Details We can simplify icmp <pred> phi(C1, C2, ...), C with phi(icmp(C1, C), icmp(C2, C), ...) provided that all comparison of constants are constants themselves.
Diff Detail Event Timeline
Comment Actions Addressed comments:
Comment Actions This breaks tests check-clang: http://45.33.8.238/linux/19487/step_7.txt Please take a look and revert for now if it takes a while to fix. Comment Actions This looks like its responsible for the exceptions.m test failures on some bots: http://lab.llvm.org:8011/builders/llvm-avr-linux/builds/2189 /home/buildbot-worker/llvm-avr-linux/llvm-avr-linux/llvm/clang/test/CodeGenObjC/exceptions.m:100:12: error: CHECK: expected string not found in input // CHECK: [[DEST1:%.*]] = phi i32 [ 0, {{%.*}} ], [ 3, {{%.*}} ] ^ <stdin>:195:37: note: scanning from here call void @objc_exception_try_exit(%struct._objc_exception_data* nonnull %exceptiondata.ptr) #5 ^ <stdin>:219:2: note: possible intended match here %1 = load i32, i32* %x, align 4, !tbaa !7 ^ Comment Actions It looks like this may introduce a dead-code elimination regression with -Oz: https://github.com/llvm/llvm-project/issues/53318
|
I don't think you need one-use check - you produce a single instruction,
and root icmp from which you started matching always goes away (is replaced by new phi)