[llvm] [InstCombine] Resolve TODO: Remove one-time check if other logic operand (Y) is constant (PR #77973)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 21 03:25:20 PST 2024
================
@@ -240,6 +240,36 @@ define i32 @lshr_or_extra_use(i32 %x, i32 %y, ptr %p) {
ret i32 %sh1
}
+define i32 @lshr_or_extra_use_shift(i32 %x, ptr %p) {
+; CHECK-LABEL: @lshr_or_extra_use_shift(
+; CHECK-NEXT: [[SH0:%.*]] = lshr i32 [[X:%.*]], 5
+; CHECK-NEXT: store i32 [[SH0]], ptr [[P:%.*]], align 4
+; CHECK-NEXT: [[R:%.*]] = lshr i32 [[X]], 12
+; CHECK-NEXT: [[SH1:%.*]] = or i32 [[R]], 192
+; CHECK-NEXT: ret i32 [[SH1]]
+;
+ %sh0 = lshr i32 %x, 5
+ %r = or i32 %sh0, 24601
+ store i32 %sh0, ptr %p
+ %sh1 = lshr i32 %r, 7
+ ret i32 %sh1
+}
----------------
nikic wrote:
It looks like this transform already happens without your patch: https://llvm.godbolt.org/z/6rbMWq65f
Is there some other fold that handles this pattern already?
https://github.com/llvm/llvm-project/pull/77973
More information about the llvm-commits
mailing list