diff --git a/lib/Target/Hexagon/HexagonPatterns.td b/lib/Target/Hexagon/HexagonPatterns.td index d432bfef7ae..05865c43f2d 100644 --- a/lib/Target/Hexagon/HexagonPatterns.td +++ b/lib/Target/Hexagon/HexagonPatterns.td @@ -1706,28 +1706,27 @@ multiclass Loadxim_pat; } -// Patterns to select load reg reg-indexed: Rs + Rt< { - let AddedComplexity = 40 in - def: Pat<(VT (Load (add I32:$Rs, (i32 (shl I32:$Rt, u2_0ImmPred:$u2))))), - (VT (MI IntRegs:$Rs, IntRegs:$Rt, imm:$u2))>; +// Pattern to select load reg reg-indexed: Rs + Rt< + : Pat<(VT (Load (add I32:$Rs, (i32 (shl I32:$Rt, u2_0ImmPred:$u2))))), + (VT (MI IntRegs:$Rs, IntRegs:$Rt, imm:$u2))>; - let AddedComplexity = 20 in - def: Pat<(VT (Load (add I32:$Rs, I32:$Rt))), - (VT (MI IntRegs:$Rs, IntRegs:$Rt, 0))>; -} +// Pattern to select load reg reg-indexed: Rs + Rt<<0. +class Loadxr_add_pat + : Pat<(VT (Load (add I32:$Rs, I32:$Rt))), + (VT (MI IntRegs:$Rs, IntRegs:$Rt, 0))>; -// Patterns to select load reg reg-indexed: Rs + Rt< { - let AddedComplexity = 40 in - def: Pat<(VT (Load (add I32:$Rs, (i32 (shl I32:$Rt, u2_0ImmPred:$u2))))), - (VT (ValueMod (MI IntRegs:$Rs, IntRegs:$Rt, imm:$u2)))>; +// Pattern to select load reg reg-indexed: Rs + Rt< + : Pat<(VT (Load (add I32:$Rs, (i32 (shl I32:$Rt, u2_0ImmPred:$u2))))), + (VT (ValueMod (MI IntRegs:$Rs, IntRegs:$Rt, imm:$u2)))>; - let AddedComplexity = 20 in - def: Pat<(VT (Load (add I32:$Rs, I32:$Rt))), - (VT (ValueMod (MI IntRegs:$Rs, IntRegs:$Rt, 0)))>; -} +// Pattern to select load reg reg-indexed: Rs + Rt<<0 with value modifier. +class Loadxrm_add_pat + : Pat<(VT (Load (add I32:$Rs, I32:$Rt))), + (VT (ValueMod (MI IntRegs:$Rs, IntRegs:$Rt, 0)))>; // Pattern to select load long-offset reg-indexed: Addr + Rt<; } -defm: Loadxim_pat; -defm: Loadxim_pat; -defm: Loadxim_pat; -defm: Loadxim_pat; -defm: Loadxim_pat; -defm: Loadxim_pat; -defm: Loadxim_pat; -defm: Loadxim_pat; -defm: Loadxim_pat; -defm: Loadxim_pat; -defm: Loadxim_pat; +let AddedComplexity = 30 in { + defm: Loadxim_pat; + defm: Loadxim_pat; + defm: Loadxim_pat; + defm: Loadxim_pat; + defm: Loadxim_pat; + defm: Loadxim_pat; + defm: Loadxim_pat; + defm: Loadxim_pat; + defm: Loadxim_pat; + defm: Loadxim_pat; + defm: Loadxim_pat; +} let AddedComplexity = 60 in { def: Loadxu_pat; @@ -1818,26 +1819,55 @@ let AddedComplexity = 60 in { def: Loadxum_pat; } -defm: Loadxr_pat; -defm: Loadxr_pat; -defm: Loadxr_pat; -defm: Loadxr_pat; -defm: Loadxr_pat; -defm: Loadxr_pat; -defm: Loadxr_pat; -defm: Loadxr_pat; -defm: Loadxr_pat; -defm: Loadxr_pat; +let AddedComplexity = 40 in { + def: Loadxr_shl_pat; + def: Loadxr_shl_pat; + def: Loadxr_shl_pat; + def: Loadxr_shl_pat; + def: Loadxr_shl_pat; + def: Loadxr_shl_pat; + def: Loadxr_shl_pat; + def: Loadxr_shl_pat; + def: Loadxr_shl_pat; + def: Loadxr_shl_pat; +} -defm: Loadxrm_pat; -defm: Loadxrm_pat; -defm: Loadxrm_pat; -defm: Loadxrm_pat; -defm: Loadxrm_pat; -defm: Loadxrm_pat; -defm: Loadxrm_pat; -defm: Loadxrm_pat; -defm: Loadxrm_pat; +let AddedComplexity = 20 in { + def: Loadxr_add_pat; + def: Loadxr_add_pat; + def: Loadxr_add_pat; + def: Loadxr_add_pat; + def: Loadxr_add_pat; + def: Loadxr_add_pat; + def: Loadxr_add_pat; + def: Loadxr_add_pat; + def: Loadxr_add_pat; + def: Loadxr_add_pat; +} + +let AddedComplexity = 40 in { + def: Loadxrm_shl_pat; + def: Loadxrm_shl_pat; + def: Loadxrm_shl_pat; + def: Loadxrm_shl_pat; + def: Loadxrm_shl_pat; + def: Loadxrm_shl_pat; + def: Loadxrm_shl_pat; + def: Loadxrm_shl_pat; + def: Loadxrm_shl_pat; +} + +let AddedComplexity = 20 in { + def: Loadxrm_add_pat; + def: Loadxrm_add_pat; + def: Loadxrm_add_pat; + def: Loadxrm_add_pat; + def: Loadxrm_add_pat; + def: Loadxrm_add_pat; + def: Loadxrm_add_pat; + def: Loadxrm_add_pat; + def: Loadxrm_add_pat; +} // Absolute address diff --git a/test/CodeGen/Hexagon/isel-prefer.ll b/test/CodeGen/Hexagon/isel-prefer.ll index 062b0b3a0ea..7094544f54b 100644 --- a/test/CodeGen/Hexagon/isel-prefer.ll +++ b/test/CodeGen/Hexagon/isel-prefer.ll @@ -54,4 +54,14 @@ b2: ret i32 %v6 } +; CHECK-LABEL: Prefer_L2_loadrub_io: +; CHECK: memub(r0+#65) +define i64 @Prefer_L2_loadrub_io(i8* %a0) #0 { +b1: + %v2 = getelementptr i8, i8* %a0, i32 65 + %v3 = load i8, i8* %v2 + %v4 = zext i8 %v3 to i64 + ret i64 %v4 +} + attributes #0 = { nounwind readnone }