You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
hi, I found a bug in TOT (instuction combiner). It tried to optimize (a<b)||
(a=b) to (a<=b), but the new predicate is wrong.
The original code:
%tmp266.i = icmp slt i32 %c.3.i, %d.292.2.i
%tmp276.i = icmp eq i32 %c.3.i, %d.292.2.i
%sel_tmp80 = or i1 %sel_tmp78, %sel_tmp79
New code:
%sel_tmp187.demorgan.i = icmp ule i32 %c.3.i, %d.292.2.i
--(should be sle)--
I looked the source codes, I guess the bug is in these lines:
struct FoldICmpLogical {
Instruction *apply(Instruction &Log) const {
Value *RV = getICmpValue(ICmpInst::isSignedPredicate(pred),
Code, LHS, RHS);
....
}
}
It only looks the second predicate: pred = eq for this example, so it return
non-signed, but actually it's signed because the other preciate is slt. I guess
both predicates should be looked at to get the correct results. I changed the
code locally, it works
Value *RV = getICmpValue(
ICmpInst::isSignedPredicate(ICI->getPredicate())
|| ICmpInst::isSignedPredicate(cast(Log.getOperand(1))-
getPredicate()),
Code, LHS, RHS);
Thanks.
The text was updated successfully, but these errors were encountered:
Yup, it looks like a bug to me. However, I don't think you need to check both
predicates. This only occurs for == and < --> <=. == is signless so you only
need to check the < case.
Extended Description
hi, I found a bug in TOT (instuction combiner). It tried to optimize (a<b)||
(a=b) to (a<=b), but the new predicate is wrong.
The original code:
%tmp266.i = icmp slt i32 %c.3.i, %d.292.2.i
%tmp276.i = icmp eq i32 %c.3.i, %d.292.2.i
%sel_tmp80 = or i1 %sel_tmp78, %sel_tmp79
New code:
%sel_tmp187.demorgan.i = icmp ule i32 %c.3.i, %d.292.2.i
--(should be sle)--
I looked the source codes, I guess the bug is in these lines:
struct FoldICmpLogical {
Instruction *apply(Instruction &Log) const {
Value *RV = getICmpValue(ICmpInst::isSignedPredicate(pred),
Code, LHS, RHS);
....
}
}
It only looks the second predicate: pred = eq for this example, so it return
non-signed, but actually it's signed because the other preciate is slt. I guess
both predicates should be looked at to get the correct results. I changed the
code locally, it works
Value *RV = getICmpValue(
ICmpInst::isSignedPredicate(ICI->getPredicate())
|| ICmpInst::isSignedPredicate(cast(Log.getOperand(1))-
Thanks.
The text was updated successfully, but these errors were encountered: