Closed
Description
https://rust.godbolt.org/z/dfWjnToef
We will simplify a comparison of scalar floats that can be represented as integers to compare the integers directly, but we don't do this for vectors:
define i32 @cmpf(i32 %x) {
%and = and i32 %x, 3
%conv = sitofp i32 %and to float
%cmp = fcmp oeq float %conv, 3.000000e+00
%sext = sext i1 %cmp to i32
ret i32 %sext
}
define <8 x i32> @vcmpf(<8 x i32> %x) {
%and = and <8 x i32> %x, <i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3>
%conv = sitofp <8 x i32> %and to <8 x float>
%cmp = fcmp oeq <8 x float> %conv, <float 3.000000e+00, float 3.000000e+00, float 3.000000e+00, float 3.000000e+00, float 3.000000e+00, float 3.000000e+00, float 3.000000e+00, float 3.000000e+00>
%sext = sext <8 x i1> %cmp to <8 x i32>
ret <8 x i32> %sext
}
opt -O3
define i32 @cmpf(i32 %x) {
%and = and i32 %x, 3
%cmp = icmp eq i32 %and, 3
%sext = sext i1 %cmp to i32
ret i32 %sext
}
define <8 x i32> @vcmpf(<8 x i32> %x) {
%and = and <8 x i32> %x, <i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3>
%conv = sitofp <8 x i32> %and to <8 x float>
%cmp = fcmp oeq <8 x float> %conv, <float 3.000000e+00, float 3.000000e+00, float 3.000000e+00, float 3.000000e+00, float 3.000000e+00, float 3.000000e+00, float 3.000000e+00, float 3.000000e+00>
%sext = sext <8 x i1> %cmp to <8 x i32>
ret <8 x i32> %sext
}