1 ; RUN: opt -mtriple=amdgcn-amd-amdhsa -amdgpu-codegenprepare -verify -S %s -o - | FileCheck %s
3 declare i1 @llvm.amdgcn.class.f32(float, i32) nounwind readnone
4 declare i1 @llvm.amdgcn.class.f64(double, i32) nounwind readnone
6 ; Trivial case, xor instruction should be removed and
7 ; the second argument of the intrinsic call should be
9 ; CHECK: @fold_negate_intrinsic_test_mask
10 ; CHECK: %1 = call i1 @llvm.amdgcn.class.f32(float %x, i32 1018)
11 define i1 @fold_negate_intrinsic_test_mask(float %x) nounwind {
12 %1 = call i1 @llvm.amdgcn.class.f32(float %x, i32 5)
17 ; Trivial case, xor instruction should be removed and
18 ; the second argument of the intrinsic call should be
20 ; CHECK: @fold_negate_intrinsic_test_mask_dbl
21 ; CHECK: %1 = call i1 @llvm.amdgcn.class.f64(double %x, i32 1018)
22 define i1 @fold_negate_intrinsic_test_mask_dbl(double %x) nounwind {
23 %1 = call i1 @llvm.amdgcn.class.f64(double %x, i32 5)
28 ; Negative test: should not transform for variable test masks
29 ; CHECK: @fold_negate_intrinsic_test_mask_neg_var
30 ; CHECK: %[[X0:.*]] = alloca i32
31 ; CHECK: %[[X1:.*]] = load i32, i32* %[[X0]]
32 ; CHECK: call i1 @llvm.amdgcn.class.f32(float %x, i32 %[[X1]])
34 define i1 @fold_negate_intrinsic_test_mask_neg_var(float %x) nounwind {
37 %2 = load i32, i32* %1
38 %3 = call i1 @llvm.amdgcn.class.f32(float %x, i32 %2)
43 ; Negative test: should not transform for multiple uses of the
44 ; intrinsic returned value
45 ; CHECK: @fold_negate_intrinsic_test_mask_neg_multiple_uses
46 ; CHECK: %[[X1:.*]] = call i1 @llvm.amdgcn.class.f32(float %x, i32 7)
47 ; CHECK: store i1 %[[X1]]
48 ; CHECK: %[[X2:.*]] = xor i1 %[[X1]]
49 define i1 @fold_negate_intrinsic_test_mask_neg_multiple_uses(float %x) nounwind {
51 %1 = call i1 @llvm.amdgcn.class.f32(float %x, i32 7)
58 ; Negative test: should not transform for a xor with no operand equal to -1
59 ; CHECK: @fold_negate_intrinsic_test_mask_neg_one
60 ; CHECK: %[[X0:.*]] = call i1 @llvm.amdgcn.class.f32(float %x, i32 7)
61 ; CHECK: xor i1 %[[X0]], false
62 define i1 @fold_negate_intrinsic_test_mask_neg_one(float %x) nounwind {
63 %1 = call i1 @llvm.amdgcn.class.f32(float %x, i32 7)