Skip to content

Commit 068893e

Browse files
kealan-barbierikarturov
authored andcommitted
gpu: jit: invert cmp instructions when required
1 parent 41e8612 commit 068893e

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/gpu/jit/codegen/codegen.hpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright 2022 Intel Corporation
2+
* Copyright 2022-2023 Intel Corporation
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -1072,9 +1072,15 @@ class expr_evaluator_t : public ir_visitor_t {
10721072
case op_kind_t::_ne: {
10731073
ir_assert(!dst.is_negated()) << "Destination can't be negated.";
10741074
ngen::InstructionModifier cmp_mod = mod;
1075-
cmp_mod |= cmp_op_to_ngen(obj.op_kind);
1076-
cmp_mod |= dst.flag_register();
1077-
host_->ecmp(cmp_mod, src0, src1);
1075+
if (!src0.is_reg_data()) {
1076+
cmp_mod |= cmp_op_to_ngen(negate_cmp_op(obj.op_kind));
1077+
cmp_mod |= dst.flag_register();
1078+
host_->ecmp(cmp_mod, src1, src0);
1079+
} else {
1080+
cmp_mod |= cmp_op_to_ngen(obj.op_kind);
1081+
cmp_mod |= dst.flag_register();
1082+
host_->ecmp(cmp_mod, src0, src1);
1083+
}
10781084
break;
10791085
}
10801086
case op_kind_t::_and: host_->eand(mod, dst, src0, src1); break;

0 commit comments

Comments
 (0)