When running the tests on PowerPC and x86, the lit test GlobalISel/trunc.ll fails at the memory sanitize step. This seems to be due to wrong invalid logic (which matches even if it shouldn't) and likely missing variable initialisation."
The problem is: in the current implementation, if both of the matches fail, there is a fallthrough. If there is no min or max following the trunc (see the test case), the match will continue. I want to make sure at least one case exists. That's why I am double-checking here.
[AMDGPU] Re-adding the changes from D93708 and fixing the clamp selection pattern.
This patch intends to re-add the changes from D93708 which were removed in d49efdc9696afee4b972c54bc3678b28c5700047 and should fix the issue adressed in this update.
This should fix the sanitizer builds and prevent applying the clamp in unwanted cases.
I extracted the corresponding parts into a separate lambda and improved the logic to only apply the combine in the corresponding cases where either a min-max or max-min pattern exists in the MIR.
As @Flakebi reverted the changes to prevent the sanitizer from failing, I re-added the changes to this revision.