This is an archive of the discontinued LLVM Phabricator instance.

[CSKY] Optimize subtraction with SUBI32/SUBI16
ClosedPublic

Authored by benshi001 on Jun 20 2023, 3:04 AM.

Diff Detail

Event Timeline

benshi001 created this revision.Jun 20 2023, 3:04 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 20 2023, 3:04 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
benshi001 requested review of this revision.Jun 20 2023, 3:04 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 20 2023, 3:04 AM
benshi001 added inline comments.Jun 20 2023, 3:05 AM
llvm/test/CodeGen/CSKY/base-i.ll
46

4096 is the upper boundary of ADDI32.

330

4096 is upper boundary of SUBI32.

benshi001 updated this revision to Diff 532847.Jun 20 2023, 3:11 AM
benshi001 added inline comments.
llvm/test/CodeGen/CSKY/base-i.ll
44

256 is the upper boundary of ADDI16.

331

256 is the upper boundary of SUBI16.

333

4097 is not optimized to SUBI32 due to out of range.

zixuan-wu added inline comments.Jun 29 2023, 2:25 AM
llvm/lib/Target/CSKY/CSKYInstrInfo.td
105

I think there is no oimm specific meaning, just use imm_neg or neg_imm would be fine.

llvm/test/CodeGen/CSKY/base-i.ll
43

Is this case related to this patch change?

benshi001 updated this revision to Diff 535692.Jun 29 2023, 2:41 AM
benshi001 updated this revision to Diff 535693.Jun 29 2023, 2:46 AM
benshi001 marked an inline comment as done.
benshi001 marked an inline comment as done.
benshi001 added inline comments.
llvm/test/CodeGen/CSKY/base-i.ll
43

Yes. I would like to show the upper boundary of ADDI16.

benshi001 marked an inline comment as done.Jun 29 2023, 2:47 AM
zixuan-wu added inline comments.Jun 29 2023, 2:52 AM
llvm/lib/Target/CSKY/CSKYInstrInfo.td
546

I think the similar Pat for SUBI16 should also be added when there is no SUBI32

benshi001 updated this revision to Diff 535711.Jun 29 2023, 4:15 AM
benshi001 marked an inline comment as done.
benshi001 added inline comments.Jun 29 2023, 7:36 PM
llvm/lib/Target/CSKY/CSKYInstrInfo.td
546

I have added in the file CSKYInstrInfo16Instr.td.

zixuan-wu accepted this revision.Jun 29 2023, 7:45 PM
This revision is now accepted and ready to land.Jun 29 2023, 7:45 PM

BTW, as the check-all test is not enough, have you run llvm-test-suite sometimes although it's not needed every patch? I think should run llvm-test-suite in qemu from time to time.

BTW, as the check-all test is not enough, have you run llvm-test-suite sometimes although it's not needed every patch? I think should run llvm-test-suite in qemu from time to time.

Thanks. I will try. Further questions,

  1. Is there any QEMU pre-build package I can use?
  2. Also csky-binutils pre-build package, where I can download?
  3. Any other tools are needed to run llvm-test-suite ? Is there a wiki page for that ?

BTW, as the check-all test is not enough, have you run llvm-test-suite sometimes although it's not needed every patch? I think should run llvm-test-suite in qemu from time to time.

Thanks. I will try. Further questions,

  1. Is there any QEMU pre-build package I can use?
  2. Also csky-binutils pre-build package, where I can download?
  3. Any other tools are needed to run llvm-test-suite ? Is there a wiki page for that ?
  1. You can download at https://xuantie.t-head.cn/community/download?id=4168444414324183040
  2. clang on csky depends to gcc runtime so it needs gcc toolchain, you can download at https://xuantie.t-head.cn/community/download?id=3854599713706024960
  3. Sorry about no document to describe the run process of llvm-test-suite in csky. But there is llvm build bot you can refer to. https://lab.llvm.org/staging/#/builders/215/builds/2795

BTW, as the check-all test is not enough, have you run llvm-test-suite sometimes although it's not needed every patch? I think should run llvm-test-suite in qemu from time to time.

Thanks. I will try. Further questions,

  1. Is there any QEMU pre-build package I can use?
  2. Also csky-binutils pre-build package, where I can download?
  3. Any other tools are needed to run llvm-test-suite ? Is there a wiki page for that ?
  1. You can download at https://xuantie.t-head.cn/community/download?id=4168444414324183040
  2. clang on csky depends to gcc runtime so it needs gcc toolchain, you can download at https://xuantie.t-head.cn/community/download?id=3854599713706024960
  3. Sorry about no document to describe the run process of llvm-test-suite in csky. But there is llvm build bot you can refer to. https://lab.llvm.org/staging/#/builders/215/builds/2795

Thanks. I will try!

This revision was automatically updated to reflect the committed changes.

BTW, as the check-all test is not enough, have you run llvm-test-suite sometimes although it's not needed every patch? I think should run llvm-test-suite in qemu from time to time.

Thanks. I will try. Further questions,

  1. Is there any QEMU pre-build package I can use?
  2. Also csky-binutils pre-build package, where I can download?
  3. Any other tools are needed to run llvm-test-suite ? Is there a wiki page for that ?
  1. You can download at https://xuantie.t-head.cn/community/download?id=4168444414324183040
  2. clang on csky depends to gcc runtime so it needs gcc toolchain, you can download at https://xuantie.t-head.cn/community/download?id=3854599713706024960
  3. Sorry about no document to describe the run process of llvm-test-suite in csky. But there is llvm build bot you can refer to. https://lab.llvm.org/staging/#/builders/215/builds/2795

I have run the SingleSource and MultiSource of the llvm-test-suite with this patch applied, there are several failures, and several link errors.

Failures of SingleSource

********************
********************
Failed Tests (1):
  test-suite :: SingleSource/Benchmarks/SmallPT/smallpt.test


Testing Time: 11971.65s
  Passed: 324
  Failed:   1

Failures of MultiSource

********************
********************
Failed Tests (4):
  test-suite :: MultiSource/Applications/ClamAV/clamscan.test
  test-suite :: MultiSource/Benchmarks/SciMark2-C/scimark2.test
  test-suite :: MultiSource/Benchmarks/TSVC/NodeSplitting-dbl/NodeSplitting-dbl.test
  test-suite :: MultiSource/Benchmarks/mafft/pairlocalalign.test


Testing Time: 11903.17s
  Passed: 185
  Failed:   4

And the cases disabled for link errors

MultiSource/Benchmarks/Bullet
MultiSource/Benchmarks/tramp3d-v4
MultiSource/Benchmarks/7zip
MultiSource/Benchmarks/PAQ8p
SingleSource/Benchmarks/Misc-C++-EH
SingleSource/Regression/C++/2003-06-08-BaseType.cpp
SingleSource/UnitTests/AtomicOps.c

Is that result OK?

zixuan-wu added a comment.EditedJul 2 2023, 7:40 PM

BTW, as the check-all test is not enough, have you run llvm-test-suite sometimes although it's not needed every patch? I think should run llvm-test-suite in qemu from time to time.

Thanks. I will try. Further questions,

  1. Is there any QEMU pre-build package I can use?
  2. Also csky-binutils pre-build package, where I can download?
  3. Any other tools are needed to run llvm-test-suite ? Is there a wiki page for that ?
  1. You can download at https://xuantie.t-head.cn/community/download?id=4168444414324183040
  2. clang on csky depends to gcc runtime so it needs gcc toolchain, you can download at https://xuantie.t-head.cn/community/download?id=3854599713706024960
  3. Sorry about no document to describe the run process of llvm-test-suite in csky. But there is llvm build bot you can refer to. https://lab.llvm.org/staging/#/builders/215/builds/2795

I have run the SingleSource and MultiSource of the llvm-test-suite with this patch applied, there are several failures, and several link errors.

Failures of SingleSource

********************
********************
Failed Tests (1):
  test-suite :: SingleSource/Benchmarks/SmallPT/smallpt.test


Testing Time: 11971.65s
  Passed: 324
  Failed:   1

Failures of MultiSource

********************
********************
Failed Tests (4):
  test-suite :: MultiSource/Applications/ClamAV/clamscan.test
  test-suite :: MultiSource/Benchmarks/SciMark2-C/scimark2.test
  test-suite :: MultiSource/Benchmarks/TSVC/NodeSplitting-dbl/NodeSplitting-dbl.test
  test-suite :: MultiSource/Benchmarks/mafft/pairlocalalign.test


Testing Time: 11903.17s
  Passed: 185
  Failed:   4

And the cases disabled for link errors

MultiSource/Benchmarks/Bullet
MultiSource/Benchmarks/tramp3d-v4
MultiSource/Benchmarks/7zip
MultiSource/Benchmarks/PAQ8p
SingleSource/Benchmarks/Misc-C++-EH
SingleSource/Regression/C++/2003-06-08-BaseType.cpp
SingleSource/UnitTests/AtomicOps.c

Is that result OK?

There is only one fail case clamscan.test, all of others should be passed.link error is about to add extra compiling flag of "-latomic".

As the two buildbot are success(exception for the only clamscan.test fails), https://lab.llvm.org/staging/#/builders/216/builds/1806 and https://lab.llvm.org/staging/#/builders/215/builds/2819, I think maybe you got wrong run command of qemu. And could you please provide your run command of qemu?

benshi001 added a comment.EditedJul 2 2023, 8:41 PM

BTW, as the check-all test is not enough, have you run llvm-test-suite sometimes although it's not needed every patch? I think should run llvm-test-suite in qemu from time to time.

Thanks. I will try. Further questions,

  1. Is there any QEMU pre-build package I can use?
  2. Also csky-binutils pre-build package, where I can download?
  3. Any other tools are needed to run llvm-test-suite ? Is there a wiki page for that ?
  1. You can download at https://xuantie.t-head.cn/community/download?id=4168444414324183040
  2. clang on csky depends to gcc runtime so it needs gcc toolchain, you can download at https://xuantie.t-head.cn/community/download?id=3854599713706024960
  3. Sorry about no document to describe the run process of llvm-test-suite in csky. But there is llvm build bot you can refer to. https://lab.llvm.org/staging/#/builders/215/builds/2795

I have run the SingleSource and MultiSource of the llvm-test-suite with this patch applied, there are several failures, and several link errors.

Failures of SingleSource

********************
********************
Failed Tests (1):
  test-suite :: SingleSource/Benchmarks/SmallPT/smallpt.test


Testing Time: 11971.65s
  Passed: 324
  Failed:   1

Failures of MultiSource

********************
********************
Failed Tests (4):
  test-suite :: MultiSource/Applications/ClamAV/clamscan.test
  test-suite :: MultiSource/Benchmarks/SciMark2-C/scimark2.test
  test-suite :: MultiSource/Benchmarks/TSVC/NodeSplitting-dbl/NodeSplitting-dbl.test
  test-suite :: MultiSource/Benchmarks/mafft/pairlocalalign.test


Testing Time: 11903.17s
  Passed: 185
  Failed:   4

And the cases disabled for link errors

MultiSource/Benchmarks/Bullet
MultiSource/Benchmarks/tramp3d-v4
MultiSource/Benchmarks/7zip
MultiSource/Benchmarks/PAQ8p
SingleSource/Benchmarks/Misc-C++-EH
SingleSource/Regression/C++/2003-06-08-BaseType.cpp
SingleSource/UnitTests/AtomicOps.c

Is that result OK?

There is only one fail case clamscan.test, all of others should be passed.link error is about to add extra compiling flag of "-latomic".

As the two buildbot are success(exception for the only clamscan.test fails), https://lab.llvm.org/staging/#/builders/216/builds/1806 and https://lab.llvm.org/staging/#/builders/215/builds/2819, I think maybe you got wrong run command of qemu. And could you please provide your run command of qemu?

I run Qemu by defining -DTEST_SUITE_RUN_UNDER="/usr/bin/qemu-cskyv2" when doing cmake, without specifying other flags. And that is fine, I see that my patch does not cause any harm, this is enough. Thanks!

BTW, as the check-all test is not enough, have you run llvm-test-suite sometimes although it's not needed every patch? I think should run llvm-test-suite in qemu from time to time.

Thanks. I will try. Further questions,

  1. Is there any QEMU pre-build package I can use?
  2. Also csky-binutils pre-build package, where I can download?
  3. Any other tools are needed to run llvm-test-suite ? Is there a wiki page for that ?
  1. You can download at https://xuantie.t-head.cn/community/download?id=4168444414324183040
  2. clang on csky depends to gcc runtime so it needs gcc toolchain, you can download at https://xuantie.t-head.cn/community/download?id=3854599713706024960
  3. Sorry about no document to describe the run process of llvm-test-suite in csky. But there is llvm build bot you can refer to. https://lab.llvm.org/staging/#/builders/215/builds/2795

I have run the SingleSource and MultiSource of the llvm-test-suite with this patch applied, there are several failures, and several link errors.

Failures of SingleSource

********************
********************
Failed Tests (1):
  test-suite :: SingleSource/Benchmarks/SmallPT/smallpt.test


Testing Time: 11971.65s
  Passed: 324
  Failed:   1

Failures of MultiSource

********************
********************
Failed Tests (4):
  test-suite :: MultiSource/Applications/ClamAV/clamscan.test
  test-suite :: MultiSource/Benchmarks/SciMark2-C/scimark2.test
  test-suite :: MultiSource/Benchmarks/TSVC/NodeSplitting-dbl/NodeSplitting-dbl.test
  test-suite :: MultiSource/Benchmarks/mafft/pairlocalalign.test


Testing Time: 11903.17s
  Passed: 185
  Failed:   4

And the cases disabled for link errors

MultiSource/Benchmarks/Bullet
MultiSource/Benchmarks/tramp3d-v4
MultiSource/Benchmarks/7zip
MultiSource/Benchmarks/PAQ8p
SingleSource/Benchmarks/Misc-C++-EH
SingleSource/Regression/C++/2003-06-08-BaseType.cpp
SingleSource/UnitTests/AtomicOps.c

Is that result OK?

There is only one fail case clamscan.test, all of others should be passed.link error is about to add extra compiling flag of "-latomic".

As the two buildbot are success(exception for the only clamscan.test fails), https://lab.llvm.org/staging/#/builders/216/builds/1806 and https://lab.llvm.org/staging/#/builders/215/builds/2819, I think maybe you got wrong run command of qemu. And could you please provide your run command of qemu?

I run Qemu by defining -DTEST_SUITE_RUN_UNDER="/usr/bin/qemu-cskyv2" when doing cmake, without specifying other flags. And that is fine, I see that my patch does not cause any harm, this is enough. Thanks!

Also need specify library path and other options. Please see https://github.com/llvm/llvm-zorg/blob/8006da069b5776b01fc5204d267e65e48f86c80e/buildbot/osuosl/master/config/builders.py#L2615.