[llvm] [InstCombine] simplify `icmp pred x, ~x` (PR #73990)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 6 08:32:21 PDT 2024
================
@@ -4,6 +4,391 @@
declare void @llvm.assume(i1)
declare void @barrier()
declare void @use.i8(i8)
+declare void @use.i1(i1)
+declare void @use.vec.i1(<2 x i1>)
+
+; X comp X^Neg_C tests, signed.
+; X s< X^Neg_C --> X s< 0
+define i1 @src_slt(i8 %x, i128 %x.128) {
+; CHECK-LABEL: @src_slt(
+; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], 0
+; CHECK-NEXT: call void @use.i1(i1 [[CMP]])
+; CHECK-NEXT: [[CMP_128:%.*]] = icmp slt i128 [[X_128:%.*]], 0
+; CHECK-NEXT: ret i1 [[CMP_128]]
+;
+ %not = xor i8 %x, -1
+ %cmp = icmp slt i8 %x, %not
+ call void @use.i1(i1 %cmp)
+ %not.128 = xor i128 -170141183460469231731687303715884105728, %x.128
+ %cmp.128 = icmp slt i128 %x.128, %not.128
+ ret i1 %cmp.128
----------------
nikic wrote:
I wouldn't combine two tests into one function in this way. It will make proof-checking more expensive and makes it look like a multi use test.
https://github.com/llvm/llvm-project/pull/73990
More information about the llvm-commits
mailing list