Optimize (add (mul x, c0), c1) -> (ADDI (MUL (ADDI, c1/c0), c0), c1%c0),
if c1/c0 and c1%c0 are simm12, while c1 is not.
Optimize (add (mul x, c0), c1) -> (MUL (ADDI, c1/c0), c0),
if c1%c0 is zero, and c1/c0 is simm12 while c1 is not.
Differential D108607
[RISCV] Optimize (add (mul x, c0), c1) benshi001 on Aug 23 2021, 8:54 PM. Authored by
Details Optimize (add (mul x, c0), c1) -> (ADDI (MUL (ADDI, c1/c0), c0), c1%c0), Optimize (add (mul x, c0), c1) -> (MUL (ADDI, c1/c0), c0),
Diff Detail Event Timeline
Comment Actions Thanks, I have changed according to your comments. What's more, I think for c1==1/0/-1, I can just skip and let other passes handle it.
Comment Actions This commit causes an infinite loop when compiling the Linux kernel: $ git bisect log # bad: [43d6991c2a4cc2ac374e68c029634f2b59ffdfdf] [IR] Look through bitcast in hasFnAttribute() # good: [6a2c2263fbca07a59b9f41181c1418df052e24d1] [X86] Improve i8 all-ones element insertion in pre-SSE4.1 git bisect start '43d6991c2a4cc2ac374e68c029634f2b59ffdfdf' '6a2c2263fbca07a59b9f41181c1418df052e24d1' # good: [792101fff749191dfd4dadabe2ecd30a4d8cd973] [RISCV] Add test cases for missed opportunity to use vfmacc.vf. NFC git bisect good 792101fff749191dfd4dadabe2ecd30a4d8cd973 # good: [20b58855e0cfc263d609e8bb59e692024ecb42aa] [CodeGen] SelectionDAGBuilder - Use const-ref iterator in for-range loops. NFCI. git bisect good 20b58855e0cfc263d609e8bb59e692024ecb42aa # bad: [08ef71ca92d9bd474ac4bbb5109e9ced19c77f0e] [InstCombine] move/add tests for trunc-of-lshr; NFC git bisect bad 08ef71ca92d9bd474ac4bbb5109e9ced19c77f0e # bad: [744ec74b305a5039dc74e2d043e1c136e06beac1] [NFC] `goto fail` has failed us in the past... git bisect bad 744ec74b305a5039dc74e2d043e1c136e06beac1 # good: [b8e7f5320825812fc4b597ee5df3dccc53fe78bb] [AMDGPU][MC][GFX10] Enabled dlc for FLAT and GLOBAL atomics git bisect good b8e7f5320825812fc4b597ee5df3dccc53fe78bb # good: [ee31ad0ab5f7d443b0bd582582a3524dcf7f13f0] [clang-offload-bundler][docs][NFC] Add archive unbundling documentation git bisect good ee31ad0ab5f7d443b0bd582582a3524dcf7f13f0 # good: [32b994bca66641cdac8586f25315daf349921ebc] [OpenCL] Defines helper function for OpenCL default address space git bisect good 32b994bca66641cdac8586f25315daf349921ebc # bad: [b3052013b43617defd777b1f3b4339540c4c07df] [RISCV] Optimize (add (mul x, c0), c1) git bisect bad b3052013b43617defd777b1f3b4339540c4c07df # first bad commit: [b3052013b43617defd777b1f3b4339540c4c07df] [RISCV] Optimize (add (mul x, c0), c1) $ cat evergreen.i int evergreen_dram_bandwidth_for_display_wm_0, evergreen_dram_bandwidth_for_display_disp_dram_allocation_0, evergreen_dram_bandwidth_for_display_bandwidth_0, evergreen_dram_bandwidth_for_display_a_0; void evergreen_dram_bandwidth_for_display() { evergreen_dram_bandwidth_for_display_a_0 = 1000 << 12; evergreen_dram_bandwidth_for_display_disp_dram_allocation_0 = 3 << 12; long tmp = evergreen_dram_bandwidth_for_display_disp_dram_allocation_0 << 13; tmp = tmp / evergreen_dram_bandwidth_for_display_a_0; evergreen_dram_bandwidth_for_display_bandwidth_0 = evergreen_dram_bandwidth_for_display_wm_0 * tmp + 2048; } $ timeout 10s clang -O2 --target=riscv64-linux-gnu -c -o /dev/null evergreen.i $ echo $? 124 This is still reproducible at current ToT (3778c1cd6ef5a3286d5d49e842a2c65fffb8f3a6). |
You just use isInt<12> from MathUtils.h and not use APInt.