Displaying 1 result from an estimated 1 matches for "zero_negone_on".
Did you mean:
zero_negone_one
2017 Jul 01
8
[IR canonicalization] 6 ways to choose {-1,0,1}
...ways to produce the common positive/zero/negative
comparison result in IR.
For the following 6 functionally equivalent C source functions, we produce
6 different versions of IR which leads to 6 different asm outputs for x86.
Which of these should we choose as canonical IR form?
1. Two selects
int zero_negone_one(int x, int y) {
if (x == y) return 0;
if (x < y) return -1;
return 1;
}
define i32 @zero_negone_one(i32, i32) {
%3 = icmp eq i32 %0, %1
%4 = icmp slt i32 %0, %1
%5 = select i1 %4, i32 -1, i32 1
%6 = select i1 %3, i32 0, i32 %5
ret i32 %6
}
2. Two selects, but different
int ze...