-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revise folding for CBitExtractBitOp (#99)
Simplify and add support for the base case of single-bit registers. While at it, add a verifier for CBitExtractBitOp.
- Loading branch information
1 parent
f932310
commit 90f688b
Showing
3 changed files
with
43 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// RUN: qss-opt %s --canonicalize | qss-opt | FileCheck %s --implicit-check-not cbit_extractbit | ||
// Verify that all oq3.cbit_extractbit operations are eliminated | ||
|
||
// CHECK: func @single_bit(%[[ARG0:.*]]: i1) -> i1 { | ||
func @single_bit(%bit: i1) -> i1 { | ||
%2 = oq3.cbit_extractbit(%bit : i1) [0] : i1 | ||
// CHECK: return %[[ARG0]] : i1 | ||
return %2 : i1 | ||
} | ||
|
||
// CHECK: func @two_bits(%[[ARG0:.*]]: !quir.cbit<2>, %[[ARG1:.*]]: i1, %[[ARG2:.*]]: i1) | ||
func @two_bits(%cbit: !quir.cbit<2>, %bit1: i1, %bit2: i1) -> i1 { | ||
%0 = oq3.cbit_insertbit(%cbit : !quir.cbit<2>)[0] = %bit1 : !quir.cbit<2> | ||
%1 = oq3.cbit_insertbit(%cbit : !quir.cbit<2>)[1] = %bit2 : !quir.cbit<2> | ||
|
||
%2 = oq3.cbit_extractbit(%1 : !quir.cbit<2>) [1] : i1 | ||
// CHECK: return %[[ARG2]] : i1 | ||
return %2 : i1 | ||
} |