[llvm] [ValueTracking] Handle flipped strictness cases in `matchSelectPattern` (PR #121958)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 8 05:24:39 PST 2025
================
@@ -19,6 +19,18 @@ define i32 @foo(i32 %h) {
ret i32 %r
}
+define i32 @foo_commuted(i32 %h) {
+; CHECK-LABEL: @foo_commuted(
+; CHECK-NEXT: [[SD:%.*]] = sdiv i32 [[H:%.*]], 2
+; CHECK-NEXT: [[R:%.*]] = call i32 @llvm.smin.i32(i32 [[SD]], i32 1)
+; CHECK-NEXT: ret i32 [[R]]
+;
+ %sd = sdiv i32 %h, 2
+ %t = icmp sgt i32 %sd, 0
+ %r = select i1 %t, i32 1, i32 %sd
+ ret i32 %r
+}
----------------
nikic wrote:
Do I understand correctly that the reason why this only matters in cases like this is that usually tryToReuseConstantFromSelectInComparison will convert it into a form that SPF recognizes, and what this change effectively does is just make the bailout for simplifying icmps that are part of a min/max pattern stronger?
https://github.com/llvm/llvm-project/pull/121958
More information about the llvm-commits
mailing list