On 4/11/23 04:21, Jakub Jelinek wrote: > Hi! > > This patch was what I've tried first before the currently committed > PR109386 fix. Still, I think it is the right thing until we have proper > full set of VREL_* relations for NANs (though it would be really nice > if op1_op2_relation could be passed either type of the comparison > operands, or even better ranges of the two operands, such that > we could choose if inversion of say VREL_LT is VREL_GE (if !MODE_HONOR_NANS > (TYPE_MODE (type))) or rhs1/rhs2 ranges are guaranteed not to include > NANs (!known_isnan && !maybe_isnan for both), or VREL_UNGE, etc. > Anyway, the current state is that for the LE/LT/GE/GT comparisons > we pretend the inverse is like for integral comparisons, which is > true only if NANs can't appear in operands, while for UNLE/UNLT/UNGE/UNGT > we don't override op1_op2_relation (so it always yields VREL_VARYING). > > Though, this patch regresses the > FAIL: gcc.dg/tree-ssa/vrp-float-6.c scan-tree-dump-times evrp "Folding predicate x_.* <= y_.* to 1" 1 > test, so am not sure what to do with it. The test has explicit > !isnan tests around it, so e.g. having the ranges passed to op1_op2_relation > would also fix it. I see no reason op1_op2_relation can't have ranges provided to it for op1 and op2.  There was no need originally.  There are times when we don't have a range handy and we want the simple answer, but if the ranges are available, we could utilize them. Attached is a patch which added op1 and op2 ranges to the routine.  GORI will utilize and pass on real ranges (which I think is the core part you want), but the consumers in fold_using_range at this point will simply pass in varying.  There are 2 consumers in fold_using_range.. one is a combiner for logicals, and the other is for export outgoing relations that are not on the branch condition.  The combiner could use real ranges, but until I fix dispatch up it is very awkward to get them.  The export one simply doesn't have them without going to an calculating them.. which would probably be expensive.. Regardless, you can at least try your enhancement using real ranges and see if this works for you. This bootstraps and has no regressions, and is fine by me if you want to use it., Andrew