[llvm] [GlobalISel] Combine (X >> C) << C to X & ((-1 >> C) << C) (PR #114821)

Dávid Ferenc Szabó via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 5 06:43:03 PST 2024


================
@@ -365,6 +365,13 @@ def bitreverse_lshr : GICombineRule<
                                                     MRI.getType(${amt}.getReg())}}); }]),
   (apply (G_SHL $d, $val, $amt))>;
 
+def lsb_bits_clearing_by_shifts_to_and: GICombineRule<
+  (defs root:$root, build_fn_matchinfo:$matchinfo),
+  (match (G_LSHR $d, $src, $amt1),
+         (G_SHL $root, $d, $amt2):$root,
----------------
dfszabo wrote:

```
[7/250] Building AArch64GenPreLegalizeGICombiner.inc...
FAILED: lib/Target/AArch64/AArch64GenPreLegalizeGICombiner.inc /home/david-szabo/work/llvm-community/build/lib/Target/AArch64/AArch64GenPreLegalizeGICombiner.inc 
cd /home/david-szabo/work/llvm-community/build && /home/david-szabo/work/llvm-community/build/NATIVE/bin/llvm-tblgen -gen-global-isel-combiner -combiners="AArch64PreLegalizerCombiner" -I /home/david-szabo/work/llvm-community/llvm-project/llvm/lib/Target/AArch64 -I/home/david-szabo/work/llvm-community/build/include -I/home/david-szabo/work/llvm-community/llvm-project/llvm/include -I /home/david-szabo/work/llvm-community/llvm-project/llvm/lib/Target /home/david-szabo/work/llvm-community/llvm-project/llvm/lib/Target/AArch64/AArch64.td --write-if-changed -o lib/Target/AArch64/AArch64GenPreLegalizeGICombiner.inc -d lib/Target/AArch64/AArch64GenPreLegalizeGICombiner.inc.d
Included from /home/david-szabo/work/llvm-community/llvm-project/llvm/lib/Target/AArch64/AArch64.td:41:
Included from /home/david-szabo/work/llvm-community/llvm-project/llvm/lib/Target/AArch64/AArch64Combine.td:12:
/home/david-szabo/work/llvm-community/llvm-project/llvm/include/llvm/Target/GlobalISel/Combine.td:368:5: error: Nested instruction '__lsb_bits_clearing_by_shifts_to_and_match_0' cannot be the same as another operand 'amt'
def lsb_bits_clearing_by_shifts_to_and: GICombineRule<
    ^
Included from /home/david-szabo/work/llvm-community/llvm-project/llvm/lib/Target/AArch64/AArch64.td:41:
/home/david-szabo/work/llvm-community/llvm-project/llvm/lib/Target/AArch64/AArch64Combine.td:68:5: error: Failed to parse one or more rules
def AArch64PreLegalizerCombiner: GICombiner<
    ^
[22/172] Building AMDGPUGenPostLegalizeGICombiner.inc...
FAILED: lib/Target/AMDGPU/AMDGPUGenPostLegalizeGICombiner.inc /home/david-szabo/work/llvm-community/build/lib/Target/AMDGPU/AMDGPUGenPostLegalizeGICombiner.inc 
cd /home/david-szabo/work/llvm-community/build && /home/david-szabo/work/llvm-community/build/NATIVE/bin/llvm-tblgen -gen-global-isel-combiner -combiners="AMDGPUPostLegalizerCombiner" -I /home/david-szabo/work/llvm-community/llvm-project/llvm/lib/Target/AMDGPU -I/home/david-szabo/work/llvm-community/build/include -I/home/david-szabo/work/llvm-community/llvm-project/llvm/include -I /home/david-szabo/work/llvm-community/llvm-project/llvm/lib/Target /home/david-szabo/work/llvm-community/llvm-project/llvm/lib/Target/AMDGPU/AMDGPUGISel.td --write-if-changed -o lib/Target/AMDGPU/AMDGPUGenPostLegalizeGICombiner.inc -d lib/Target/AMDGPU/AMDGPUGenPostLegalizeGICombiner.inc.d
Included from /home/david-szabo/work/llvm-community/llvm-project/llvm/lib/Target/AMDGPU/AMDGPUGISel.td:14:
Included from /home/david-szabo/work/llvm-community/llvm-project/llvm/lib/Target/AMDGPU/AMDGPUCombine.td:9:
/home/david-szabo/work/llvm-community/llvm-project/llvm/include/llvm/Target/GlobalISel/Combine.td:368:5: error: Nested instruction '__lsb_bits_clearing_by_shifts_to_and_match_0' cannot be the same as another operand 'amt'
def lsb_bits_clearing_by_shifts_to_and: GICombineRule<
    ^
Included from /home/david-szabo/work/llvm-community/llvm-project/llvm/lib/Target/AMDGPU/AMDGPUGISel.td:14:
/home/david-szabo/work/llvm-community/llvm-project/llvm/lib/Target/AMDGPU/AMDGPUCombine.td:160:5: error: Failed to parse one or more rules
def AMDGPUPostLegalizerCombiner: GICombiner<
    ^
[23/172] Building AMDGPUGenPreLegalizeGICombiner.inc...
FAILED: lib/Target/AMDGPU/AMDGPUGenPreLegalizeGICombiner.inc /home/david-szabo/work/llvm-community/build/lib/Target/AMDGPU/AMDGPUGenPreLegalizeGICombiner.inc 
cd /home/david-szabo/work/llvm-community/build && /home/david-szabo/work/llvm-community/build/NATIVE/bin/llvm-tblgen -gen-global-isel-combiner -combiners="AMDGPUPreLegalizerCombiner" -I /home/david-szabo/work/llvm-community/llvm-project/llvm/lib/Target/AMDGPU -I/home/david-szabo/work/llvm-community/build/include -I/home/david-szabo/work/llvm-community/llvm-project/llvm/include -I /home/david-szabo/work/llvm-community/llvm-project/llvm/lib/Target /home/david-szabo/work/llvm-community/llvm-project/llvm/lib/Target/AMDGPU/AMDGPUGISel.td --write-if-changed -o lib/Target/AMDGPU/AMDGPUGenPreLegalizeGICombiner.inc -d lib/Target/AMDGPU/AMDGPUGenPreLegalizeGICombiner.inc.d
Included from /home/david-szabo/work/llvm-community/llvm-project/llvm/lib/Target/AMDGPU/AMDGPUGISel.td:14:
Included from /home/david-szabo/work/llvm-community/llvm-project/llvm/lib/Target/AMDGPU/AMDGPUCombine.td:9:
/home/david-szabo/work/llvm-community/llvm-project/llvm/include/llvm/Target/GlobalISel/Combine.td:368:5: error: Nested instruction '__lsb_bits_clearing_by_shifts_to_and_match_0' cannot be the same as another operand 'amt'
def lsb_bits_clearing_by_shifts_to_and: GICombineRule<
    ^
Included from /home/david-szabo/work/llvm-community/llvm-project/llvm/lib/Target/AMDGPU/AMDGPUGISel.td:14:
/home/david-szabo/work/llvm-community/llvm-project/llvm/lib/Target/AMDGPU/AMDGPUCombine.td:154:5: error: Failed to parse one or more rules
def AMDGPUPreLegalizerCombiner: GICombiner<
    ^
[24/172] Building AMDGPUGenGlobalISel.inc...
ninja: build stopped: subcommand failed.

```

https://github.com/llvm/llvm-project/pull/114821


More information about the llvm-commits mailing list