-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Closed
Labels
llvm:instcombineCovers the InstCombine, InstSimplify and AggressiveInstCombine passesCovers the InstCombine, InstSimplify and AggressiveInstCombine passesquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!
Description
This here pattern
define i8 @src(i8 noundef %x, i8 noundef %y) {
%z = call i8 @llvm.umin.i8(i8 %x, i8 %y)
%z2 = sub i8 %x, %z
ret i8 %z2
}
define i8 @tgt(i8 noundef %x, i8 noundef %y) {
%z = call i8 @llvm.usub.sat(i8 %x, i8 %y)
ret i8 %z
}shows up a bunch in code generate at least from IREE if not general MLIR projects (once reasoning was done, often MLIR side, to convert what used to be smins into umins).
I think this is a good candidate for an InstCombine, since it shrinks the IR and removes duplicate uses of %x. It also looks to me like most targets support usubsat so this is a safe transform in general.
Metadata
Metadata
Assignees
Labels
llvm:instcombineCovers the InstCombine, InstSimplify and AggressiveInstCombine passesCovers the InstCombine, InstSimplify and AggressiveInstCombine passesquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!