[all-commits] [llvm/llvm-project] b88e8c: LowerTypeTests: Avoid zext of ptrtoint ConstantExpr.

Peter Collingbourne via All-commits all-commits at lists.llvm.org
Thu Jun 5 11:10:56 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b88e8cceb9d079a90dbff5a0fd9aaccfedde01db
      https://github.com/llvm/llvm-project/commit/b88e8cceb9d079a90dbff5a0fd9aaccfedde01db
  Author: Peter Collingbourne <peter at pcc.me.uk>
  Date:   2025-06-05 (Thu, 05 Jun 2025)

  Changed paths:
    M llvm/lib/Transforms/IPO/LowerTypeTests.cpp
    M llvm/test/ThinLTO/X86/cfi-devirt.ll
    M llvm/test/Transforms/LowerTypeTests/export-allones.ll
    M llvm/test/Transforms/LowerTypeTests/export-bytearray.ll
    M llvm/test/Transforms/LowerTypeTests/export-icall.ll
    M llvm/test/Transforms/LowerTypeTests/import.ll
    M llvm/test/Transforms/LowerTypeTests/simplify.ll

  Log Message:
  -----------
  LowerTypeTests: Avoid zext of ptrtoint ConstantExpr.

In the LowerTypeTests pass we used to create IR like this:

  %3 = zext i8 ptrtoint (ptr @__typeid_allones7_align to i8) to i64
  %4 = lshr i64 %2, %3
  %5 = zext i8 sub (i8 64, i8 ptrtoint (ptr @__typeid_allones7_align to i8)) to i64
  %6 = shl i64 %2, %5
  %7 = or i64 %4, %6

This is because when this code was originally written there were no
funnel shifts and as I recall it was necessary to create an i8 and zext
to pointer width (instead of just having a ptrtoint of pointer width)
in order for the shl/shr/or to be pattern matched to ror. At the time
this caused no problems because there existed a zext ConstantExpr. But
after zext ConstantExpr was removed in #71040, the newly present zext
instruction can prevent pattern matching the rotate, for example if
the zext gets hoisted to a loop preheader or common ancestor of the
check. LowerTypeTests was made to use fshr in #141735 so now we can
ptrtoint to pointer width and stop creating the zext.

Reviewers: fmayer, nikic

Reviewed By: nikic

Pull Request: https://github.com/llvm/llvm-project/pull/142886



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list