Skip to content

Commit

Permalink
Revert "[NVPTX] Improve lowering of v2i16 logical ops. (#67073)"
Browse files Browse the repository at this point in the history
This reverts commit 6485790.

Caused xla/tests:float8_test_gpu to fail
```
LLVM ERROR: Cannot select: t118: v2i16 = or t375, t401
  t375: v2i16 = BUILD_VECTOR t374, t372
    t374: i16 = select t247, Constant:i16<8960>, t360
      t247: i1 = setcc t199, Constant:i16<7>, seteq:ch
        t199: i16 = extract_vector_elt t187, Constant:i64<0>
          t187: v2i16 = and t183, t410
            t183: v2i16 = BUILD_VECTOR t383, t384
            ...
```

Acked by author to revert
  • Loading branch information
MaskRay committed Sep 23, 2023
1 parent d230bf3 commit d9a0163
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 78 deletions.
7 changes: 4 additions & 3 deletions llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -642,9 +642,10 @@ NVPTXTargetLowering::NVPTXTargetLowering(const NVPTXTargetMachine &TM,
setI16x2OperationAction(ISD::UREM, MVT::v2i16, Legal, Custom);

// Other arithmetic and logic ops are unsupported.
setOperationAction({ISD::SDIV, ISD::UDIV, ISD::SRA, ISD::SRL, ISD::MULHS,
ISD::MULHU, ISD::FP_TO_SINT, ISD::FP_TO_UINT,
ISD::SINT_TO_FP, ISD::UINT_TO_FP},
setOperationAction({ISD::AND, ISD::OR, ISD::XOR, ISD::SDIV, ISD::UDIV,
ISD::SRA, ISD::SRL, ISD::MULHS, ISD::MULHU,
ISD::FP_TO_SINT, ISD::FP_TO_UINT, ISD::SINT_TO_FP,
ISD::UINT_TO_FP},
MVT::v2i16, Expand);

setOperationAction(ISD::ADDC, MVT::i32, Legal);
Expand Down
11 changes: 0 additions & 11 deletions llvm/lib/Target/NVPTX/NVPTXInstrInfo.td
Original file line number Diff line number Diff line change
Expand Up @@ -1486,17 +1486,6 @@ defm OR : BITWISE<"or", or>;
defm AND : BITWISE<"and", and>;
defm XOR : BITWISE<"xor", xor>;

// Lower logical ops as bitwise ops on b32.
// By this point the constants get legalized into a bitcast from i32, so that's
// what we need to match here.
def: Pat<(or Int32Regs:$a, (v2i16 (bitconvert (i32 imm:$b)))),
(ORb32ri Int32Regs:$a, imm:$b)>;
def: Pat<(xor Int32Regs:$a, (v2i16 (bitconvert (i32 imm:$b)))),
(XORb32ri Int32Regs:$a, imm:$b)>;
def: Pat<(and Int32Regs:$a, (v2i16 (bitconvert (i32 imm:$b)))),
(ANDb32ri Int32Regs:$a, imm:$b)>;


def NOT1 : NVPTXInst<(outs Int1Regs:$dst), (ins Int1Regs:$src),
"not.pred \t$dst, $src;",
[(set Int1Regs:$dst, (not Int1Regs:$src))]>;
Expand Down
64 changes: 0 additions & 64 deletions llvm/test/CodeGen/NVPTX/i16x2-instructions.ll
Original file line number Diff line number Diff line change
Expand Up @@ -235,70 +235,6 @@ define <2 x i16> @test_mul(<2 x i16> %a, <2 x i16> %b) #0 {
ret <2 x i16> %r
}

;; Logical ops are available on all GPUs as regular 32-bit logical ops
; COMMON-LABEL: test_or(
; COMMON-DAG: ld.param.u32 [[A:%r[0-9]+]], [test_or_param_0];
; COMMON-DAG: ld.param.u32 [[B:%r[0-9]+]], [test_or_param_1];
; COMMON-NEXT: or.b32 [[R:%r[0-9]+]], [[A]], [[B]];
; COMMON-NEXT: st.param.b32 [func_retval0+0], [[R]];
; COMMON-NEXT: ret;
define <2 x i16> @test_or(<2 x i16> %a, <2 x i16> %b) #0 {
%r = or <2 x i16> %a, %b
ret <2 x i16> %r
}

; Check that we can lower or with immediate arguments.
; COMMON-LABEL: test_or_imm_0(
; COMMON-DAG: ld.param.u32 [[A:%r[0-9]+]], [test_or_imm_0_param_0];
; COMMON-NEXT: or.b32 [[R:%r[0-9]+]], [[A]], 131073;
; COMMON-NEXT: st.param.b32 [func_retval0+0], [[R]];
; COMMON-NEXT: ret;
define <2 x i16> @test_or_imm_0(<2 x i16> %a) #0 {
%r = or <2 x i16> <i16 1, i16 2>, %a
ret <2 x i16> %r
}

; COMMON-LABEL: test_or_imm_1(
; COMMON-DAG: ld.param.u32 [[B:%r[0-9]+]], [test_or_imm_1_param_0];
; COMMON-NEXT: or.b32 [[R:%r[0-9]+]], [[A]], 131073;
; COMMON-NEXT: st.param.b32 [func_retval0+0], [[R]];
; COMMON-NEXT: ret;
define <2 x i16> @test_or_imm_1(<2 x i16> %a) #0 {
%r = or <2 x i16> %a, <i16 1, i16 2>
ret <2 x i16> %r
}

; COMMON-LABEL: test_xor(
; COMMON-DAG: ld.param.u32 [[A:%r[0-9]+]], [test_xor_param_0];
; COMMON-DAG: ld.param.u32 [[B:%r[0-9]+]], [test_xor_param_1];
; COMMON-NEXT: xor.b32 [[R:%r[0-9]+]], [[A]], [[B]];
; COMMON-NEXT: st.param.b32 [func_retval0+0], [[R]];
; COMMON-NEXT: ret;
define <2 x i16> @test_xor(<2 x i16> %a, <2 x i16> %b) #0 {
%r = xor <2 x i16> %a, %b
ret <2 x i16> %r
}

; Check that we can lower xor with immediate arguments.
; COMMON-LABEL: test_xor_imm_0(
; COMMON-DAG: ld.param.u32 [[A:%r[0-9]+]], [test_xor_imm_0_param_0];
; COMMON-NEXT: xor.b32 [[R:%r[0-9]+]], [[A]], 131073;
; COMMON-NEXT: st.param.b32 [func_retval0+0], [[R]];
; COMMON-NEXT: ret;
define <2 x i16> @test_xor_imm_0(<2 x i16> %a) #0 {
%r = xor <2 x i16> <i16 1, i16 2>, %a
ret <2 x i16> %r
}

; COMMON-LABEL: test_xor_imm_1(
; COMMON-DAG: ld.param.u32 [[B:%r[0-9]+]], [test_xor_imm_1_param_0];
; COMMON-NEXT: xor.b32 [[R:%r[0-9]+]], [[A]], 131073;
; COMMON-NEXT: st.param.b32 [func_retval0+0], [[R]];
; COMMON-NEXT: ret;
define <2 x i16> @test_xor_imm_1(<2 x i16> %a) #0 {
%r = xor <2 x i16> %a, <i16 1, i16 2>
ret <2 x i16> %r
}

; COMMON-LABEL: .func test_ldst_v2i16(
; COMMON-DAG: ld.param.u64 [[A:%rd[0-9]+]], [test_ldst_v2i16_param_0];
Expand Down

0 comments on commit d9a0163

Please sign in to comment.