Closed regehr closed 7 months ago
This is a canonicalization dropping transform, which is supposed to be allowed
I think it's a bug in LLVM. This is only correct if the select has the 'nnan' flag or when the comparison is reversed (to ogt). 'fcmp ole' returns false for NaNs. and thus the select will always return the input as-is. But fabs sets the sign bit to 0, so it may change the sign of NaNs. Thus either LangRef needs further patching or LLVM is wrong here.
There's an open LLVM bug report to track these select folds: https://github.com/llvm/llvm-project/issues/49625
I'm seeing a fair number of value mismatches from FP optimizations in the middle end, such as the one below, and also ones where it's turning an SNaN output into a QNaN, and also ones where it's making things more poisonous. Are these real bugs that I should report? Or are some of these Alive being overly sensitive?
To be clear, these are coming up in the context of the ARM lifter, which relies on the middle end, but the issues I'm seeing are in the middle end, not the backend.