[llvm] [InstCombine] Canonicalize non-i8 gep of mul to i8 (PR #96606)

David Green via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 12 09:10:29 PDT 2024


================
@@ -1057,8 +1057,8 @@ define i8 @test_gep_bitcast_array_different_size_element(ptr %arr, i64 %N) {
 
 define i64 @test_gep_bitcast_array_same_size_element_as1(ptr addrspace(1) %arr, i16 %N) {
 ; CHECK-LABEL: @test_gep_bitcast_array_same_size_element_as1(
-; CHECK-NEXT:    [[V:%.*]] = shl i16 [[N:%.*]], 3
-; CHECK-NEXT:    [[T:%.*]] = getelementptr i64, ptr addrspace(1) [[ARR:%.*]], i16 [[V]]
+; CHECK-NEXT:    [[T_IDX:%.*]] = shl i16 [[N:%.*]], 6
+; CHECK-NEXT:    [[T:%.*]] = getelementptr i8, ptr addrspace(1) [[ARR:%.*]], i16 [[T_IDX]]
 ; CHECK-NEXT:    [[X:%.*]] = load i64, ptr addrspace(1) [[T]], align 4
----------------
davemgreen wrote:

Hi - I'm not sure. I think if the multiply would have overflowed before then it is still fine for it to overflow after the canonicalization. We only generate a mul, not the shift directly, and let instcombine convert it if necessary.

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


More information about the llvm-commits mailing list