Displaying 2 results from an estimated 2 matches for "sel_1_or_0".
2016 Sep 29
2
IR canonicalization: select or bool math?
...ruction, but let me go against my
intuition and try to list two reasons why we should prefer selects:
* Folding operations into selects: it is trivial to transform
f(select X, Const0, Const1) to select X, f(Const0), f(Const1),
while doing that can be difficult for zexts.
define i32 @sel_1_or_0(i1 %a) {
%b = select i1 %a, i32 1, i32 0
%k = add i32 %b, 50
ret i32 %k
}
==>
define i32 @sel_1_or_0(i1 %a) {
%b = select i1 %a, i32 51, i32 50
ret i32 %b
}
but
define i32 @sel_1_or_0(i1 %a) {
%b = zext i1 %a to i32
%k = add i...
2016 Sep 28
4
IR canonicalization: select or bool math?
..., please disregard prior knowledge of how this is
handled by instcombine or how this is lowered by your favorite target...of
course we'll fix it. :) Some answers in the links below if you do want to
know.
Which, if any, of these is canonical?
1. Is a zext simpler than a select?
a. define i32 @sel_1_or_0(i1 %a) {
%b = select i1 %a, i32 1, i32 0
ret i32 %b
}
b. define i32 @sel_1_or_0(i1 %a) {
%b = zext i1 %a to i32
ret i32 %b
}
2. What if we have to 'not' the bool?
a. define i32 @sel_0_or_1(i1 %a) {
%b = select i1 %a, i32 0, i32 1
ret i32 %b
}
b. define i32 @sel_0_or_1(i1 %a)...