https://llvm.org/bugs/show_bug.cgi?id=31125
Bug ID: 31125 Summary: [InstCombine] pairs of icmps of phis of constants are not simplified Product: libraries Version: 3.9 Hardware: PC OS: Linux Status: NEW Severity: normal Priority: P Component: Scalar Optimizations Assignee: unassignedb...@nondot.org Reporter: arie...@mail.tau.ac.il CC: llvm-bugs@lists.llvm.org Classification: Unclassified Created attachment 17635 --> https://llvm.org/bugs/attachment.cgi?id=17635&action=edit A more complicated case that simplifycfg can't optimize This seems to be the root cause of Rust issue https://github.com/rust-lang/rust/issues/37930, which is causing slowness in futures-rs. Minified reproducer: define i8 @start(i8* %addr) { entry-block: br label %main-loop main-loop: %phi = phi i8 [ 0, %entry-block ], [ 1, %core ] %switch_0 = icmp eq i8 %phi, 0 store volatile i8 0, i8* %addr br i1 %switch_0, label %busy-wait-phi-0, label %exit busy-wait-phi-0: %load = load volatile i8, i8* %addr %icmp = icmp eq i8 %load, 0 br i1 %icmp, label %busy-wait-phi-0, label %core core: %switch_1 = icmp eq i8 %phi, 1 br i1 %switch_1, label %trap, label %main-loop trap: ret i8 1 exit: ret i8 0 } In the reproducer, `trap` can never be hit: %phi is obviously always 0 when you enter core. SCCP should notice this (SimplifyCfg notices this simple case - but it does not handle more complicated cases), but it seems to work only on booleans, and relies on InstCombine to simplify integers to booleans. If all icmps of the phi compare it against the same integer (e.g. if the `eq 1` test is replaced with an `ne 0`), everything works well: InstCombine replaces the integer with a boolean of the form %phi = phi i1 [ true, %entry-block ], [ false, %core ] and SCCP can work its magic. However, if, as above, one of the icmps is against an `eq 1` and another is against an `eq 0`, this optimization, and therefore SCCP, can't take place. This might better be done by extending SCCP to integers instead of in InstCombine. -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs