• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc -march=nvptx -verify-machineinstrs < %s | FileCheck %s
2
3; Tests the following pattern:
4; (X & 8) != 0 --> (X & 8) >> 3
5
6; This produces incorrect code in general when boolean false is
7; represented as a negative one. There is however a special
8; case when the type has a bitsize of 1, for which the false
9; value will be identical regardless of the boolean representation.
10; Check that the optimization triggers in this case.
11
12; CHECK-LABEL: @pow2_mask_cmp
13; CHECK: bfe.u32 {{%r[0-9]+}}, {{%r[0-9]+}}, 3, 1
14define i32 @pow2_mask_cmp(i32 %x) {
15  %a = and i32 %x, 8
16  %cmp = icmp ne i32 %a, 0
17  %r = zext i1 %cmp to i32
18  ret i32 %r
19}
20