Page MenuHomePhabricator

[InstCombine] Make `FoldOpIntoSelect` handle non-constants and use condition to deduce constants.
Needs RevisionPublic

Authored by goldstein.w.n on Fri, Mar 17, 7:05 PM.

Details

Summary
  1. Make FoldOpIntoSelect handle non-constants by returning nullptr instead of aborting.
  2. Make the fold use the information present in the condition for deducing constants i.e: ` %c = icmp eq i8 %x, 10 %s = select i1 %c, i8 3, i8 2 %r = mul i8 %x, %s `

    If we fold the mul into the select, on the true side we insert 10 for %x in the mul.

Diff Detail

Unit TestsFailed

TimeTest
170 msx64 debian > Flang.Driver::code-gen-rv64.f90
Script: -- : 'RUN: at line 5'; rm -f /var/lib/buildkite-agent/builds/llvm-project/build/tools/flang/test/Driver/Output/code-gen-rv64.f90.tmp.o

Event Timeline

goldstein.w.n created this revision.Fri, Mar 17, 7:05 PM
Herald added a project: Restricted Project. · View Herald TranscriptFri, Mar 17, 7:05 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
goldstein.w.n requested review of this revision.Fri, Mar 17, 7:05 PM
Herald added a project: Restricted Project. · View Herald TranscriptFri, Mar 17, 7:05 PM
nikic requested changes to this revision.Tue, Mar 21, 2:04 AM

Can you please rebase over https://github.com/llvm/llvm-project/commit/d0de2c51c9a9fc0fedb97ee98f61ce08cb34972b? I hope that will clarify what the actual change here is, because making foldOperationIntoSelectOperand() fallible doesn't make a whole lot of sense.

This revision now requires changes to proceed.Tue, Mar 21, 2:04 AM