Skip to content

Commit

Permalink
Mask out not-demanded bits for concrete interpreter (google#830)
Browse files Browse the repository at this point in the history
  • Loading branch information
manasij7479 committed Sep 14, 2021
1 parent ac139a2 commit 73ca4ad
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/Infer/Pruning.cpp
Expand Up @@ -414,7 +414,12 @@ bool PruningManager::isInfeasible(souper::Inst *RHS,
} else {
auto RHSV = ConcreteInterpreters[I].evaluateInst(RHS);
if (RHSV.hasValue()) {
if (Val != RHSV.getValue()) {
auto RVal = RHSV.getValue();
if (SC.LHS->DemandedBits != 0) {
Val &= SC.LHS->DemandedBits;
RVal &= SC.LHS->DemandedBits;
}
if (Val != RVal) {
if (StatsLevel > 2) {
llvm::errs() << " RHS value = " << RHSV.getValue() << "\n";
llvm::errs() << " pruned using concrete interpreter!\n";
Expand Down
18 changes: 18 additions & 0 deletions test/Infer/pruning/dontprune.opt
@@ -0,0 +1,18 @@
; REQUIRES: synthesis

; RUN: %souper-check -try-dataflow-pruning %s > %t
; RUN: %FileCheck %s < %t

; CHECK: Pruning failed

%0 = block 2
%1:i64 = var
%2:i64 = lshr %1, 16:i64
%3:i64 = var
%4:i64 = lshr %3, 16:i64
%5:i64 = phi %0, %2, %4
%6:i16 = trunc %5
%7:i32 = zext %6
infer %7 (demandedBits=00000000000000001111111100000000)
%8:i32 = trunc %5
result %8

0 comments on commit 73ca4ad

Please sign in to comment.