From: Roman Lebedev Date: Tue, 13 Aug 2019 08:14:13 +0000 (+0000) Subject: [NFC][InstCombine] Non-canonical clamp pattern: non-canonical predicate tests X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=22809c3933cef23eb591c90b512977263c37056d;p=llvm [NFC][InstCombine] Non-canonical clamp pattern: non-canonical predicate tests We can't handle 'uge' case because we can't ever get it, there needs to be extra use on that compare or else it will be canonicalized, but because of extra use we can't handle it. 'sge' case we can have. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@368656 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Transforms/InstCombine/canonicalize-clamp-like-pattern-between-negative-and-positive-thresholds.ll b/test/Transforms/InstCombine/canonicalize-clamp-like-pattern-between-negative-and-positive-thresholds.ll index c23bf366079..141bf660ee4 100644 --- a/test/Transforms/InstCombine/canonicalize-clamp-like-pattern-between-negative-and-positive-thresholds.ll +++ b/test/Transforms/InstCombine/canonicalize-clamp-like-pattern-between-negative-and-positive-thresholds.ll @@ -444,3 +444,46 @@ define <2 x i32> @t21_ult_slt_vec_nonsplat(<2 x i32> %x, <2 x i32> %replacement_ %r = select <2 x i1> %t3, <2 x i32> %x, <2 x i32> %t1 ret <2 x i32> %r } + +; Non-canonical predicates + +declare void @use2xi1(<2 x i1>) + +declare void @use(<2 x i1>) +define <2 x i32> @t22_uge_slt(<2 x i32> %x, <2 x i32> %replacement_low, <2 x i32> %replacement_high) { +; CHECK-LABEL: @t22_uge_slt( +; CHECK-NEXT: [[T0:%.*]] = icmp slt <2 x i32> [[X:%.*]], +; CHECK-NEXT: [[T1:%.*]] = select <2 x i1> [[T0]], <2 x i32> [[REPLACEMENT_LOW:%.*]], <2 x i32> [[REPLACEMENT_HIGH:%.*]] +; CHECK-NEXT: [[T2:%.*]] = add <2 x i32> [[X]], +; CHECK-NEXT: [[T3:%.*]] = icmp uge <2 x i32> [[T2]], +; CHECK-NEXT: call void @use2xi1(<2 x i1> [[T3]]) +; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[T3]], <2 x i32> [[T1]], <2 x i32> [[X]] +; CHECK-NEXT: ret <2 x i32> [[R]] +; + %t0 = icmp slt <2 x i32> %x, + %t1 = select <2 x i1> %t0, <2 x i32> %replacement_low, <2 x i32> %replacement_high + %t2 = add <2 x i32> %x, + %t3 = icmp uge <2 x i32> %t2, + call void @use2xi1(<2 x i1> %t3) + %r = select <2 x i1> %t3, <2 x i32> %t1, <2 x i32> %x + ret <2 x i32> %r +} + +define <2 x i32> @t23_ult_sge(<2 x i32> %x, <2 x i32> %replacement_low, <2 x i32> %replacement_high) { +; CHECK-LABEL: @t23_ult_sge( +; CHECK-NEXT: [[T0:%.*]] = icmp sge <2 x i32> [[X:%.*]], +; CHECK-NEXT: call void @use2xi1(<2 x i1> [[T0]]) +; CHECK-NEXT: [[T1:%.*]] = select <2 x i1> [[T0]], <2 x i32> [[REPLACEMENT_HIGH:%.*]], <2 x i32> [[REPLACEMENT_LOW:%.*]] +; CHECK-NEXT: [[T2:%.*]] = add <2 x i32> [[X]], +; CHECK-NEXT: [[T3:%.*]] = icmp ult <2 x i32> [[T2]], +; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[T3]], <2 x i32> [[X]], <2 x i32> [[T1]] +; CHECK-NEXT: ret <2 x i32> [[R]] +; + %t0 = icmp sge <2 x i32> %x, + call void @use2xi1(<2 x i1> %t0) + %t1 = select <2 x i1> %t0, <2 x i32> %replacement_high, <2 x i32> %replacement_low + %t2 = add <2 x i32> %x, + %t3 = icmp ult <2 x i32> %t2, + %r = select <2 x i1> %t3, <2 x i32> %x, <2 x i32> %t1 + ret <2 x i32> %r +}