xref: /llvm-project/llvm/test/CodeGen/PowerPC/zext-and-cmp.ll (revision 5403c59c608c08c8ecd4303763f08eb046eb5e4d)
1; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu  < %s | FileCheck %s
2
3; Test that we recognize that an 'and' instruction that feeds a comparison
4; to zero can be simplifed by using the record form when one of its operands
5; is known to be zero extended.
6
7@k = local_unnamed_addr global i32 0, align 4
8
9; Function Attrs: norecurse nounwind
10define signext i32 @cmplwi(ptr nocapture readonly %p, ptr nocapture readonly %q, i32 signext %j, i32 signext %r10) {
11entry:
12  %0 = load i32, ptr %q, align 4
13  %shl = shl i32 %0, %j
14  %1 = load i32, ptr %p, align 4
15  %and = and i32 %shl, %r10
16  %and1 = and i32 %and, %1
17  %tobool = icmp eq i32 %and1, 0
18  br i1 %tobool, label %cleanup, label %if.then
19
20if.then:
21  store i32 %j, ptr @k, align 4
22  br label %cleanup
23
24cleanup:
25  %retval.0 = phi i32 [ 0, %if.then ], [ 1, %entry ]
26  ret i32 %retval.0
27}
28
29; CHECK-LABEL: cmplwi:
30; CHECK:      lwz [[T1:[0-9]+]], 0(3)
31; CHECK:      and. {{[0-9]+}}, {{[0-9]+}}, [[T1]]
32; CHECK-NOT:  cmplwi
33; CHECK-NEXT: beq      0,
34