[PATCH] D152059: [AVR] Replace shift-to-loop IR pass with common shift code

Patryk Wychowaniec via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 3 03:48:37 PDT 2023


Patryk27 added a comment.

Whoopsie, apparently this patch introduces some regression - e.g. the following code now doesn't compile:

  fn reverse_bits(mut x: u8) -> u8 {
      let mut y: u8 = 0;
      let mut i = 7;
  
      while i != 0 {
          if x & 0x01 != 0 {
              y |= 0x80;
          }
  
          y = y.rotate_left(1);
          x >>= 1;
          i -= 1;
      }
  
      y
  }
  
  #[no_mangle]
  pub extern "C" fn main() {
      let x = black_box(123);
      let x = reverse_bits(x);
      let x = black_box(x);
  
      loop {
          //
      }
  }

... saying:

  LLVM ERROR: Cannot select: t71: i8 = ROL t52
    t52: i8 = or t72, t51
      t72: i8 = ROL t48
        t48: i8 = or t73, t47
          t73: i8 = ROL t43
            t43: i8 = or t74, t42
              t74: i8 = ROL t38
                t38: i8 = or t75, t86
                  t75: i8 = ROL t33
                    t33: i8 = or t76, t32
  
  
                  t86: i8 = and t77, Constant:i8<-128>
                    t77: i8 = <<Unknown Target Node #459>> t15
  
                    t26: i8 = Constant<-128>
              t42: i8 = and t84, Constant:i8<-128>
                t84: i8 = LSL t83
                  t83: i8 = LSL t82
                    t82: i8 = LSL t15
  
                t26: i8 = Constant<-128>
          t47: i8 = and t83, Constant:i8<-128>
            t83: i8 = LSL t82
              t82: i8 = LSL t15
                t15: i8,ch = load<(dereferenceable load (s8) from %ir.1)> t85, FrameIndex:i16<1>, undef:i16
                  t4: i16 = FrameIndex<1>
                  t6: i16 = undef
            t26: i8 = Constant<-128>
      t51: i8 = and t82, Constant:i8<-128>
        t82: i8 = LSL t15
          t15: i8,ch = load<(dereferenceable load (s8) from %ir.1)> t85, FrameIndex:i16<1>, undef:i16
            t4: i16 = FrameIndex<1>
            t6: i16 = undef
        t26: i8 = Constant<-128>

Curiously, selection works for types larger than u8.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152059/new/

https://reviews.llvm.org/D152059



More information about the llvm-commits mailing list